Exemple #1
0
def cmdMakeSubmission(n_estimators, k, n, trainFile, testFile, outFile):
  dt = datetime.now()
  print 'load train data... ',
  trainRows = data.loadTrainJson(trainFile)
  print str(datetime.now() - dt)

  dt = datetime.now()
  print 'load test data... ',
  testRows = data.loadTestJson(testFile)
  print str(datetime.now() - dt)

  dt = datetime.now()
  print 'train model'
  m = StackModel(n_estimators, k, n)
  m.train(trainRows)
  print 'train model, done in %s' % str(datetime.now() - dt)

  m.estimator.n_jobs = 1

  dt = datetime.now()
  print 'generate submission'
  with open(outFile, 'w') as f:
    f.write('Insult,Date,Comment\n')
    f.writelines(('%f,%s,%s\n' % (m.classify1(row), row.dt, row.rawText) for row in testRows))

  print 'generate submission, done in %s' % str(datetime.now() - dt)
Exemple #2
0
def cmdMakeSubmission(n_estimators, k, n, trainFile, testFile, outFile):
    dt = datetime.now()
    print 'load train data... ',
    trainRows = data.loadTrainJson(trainFile)
    print str(datetime.now() - dt)

    dt = datetime.now()
    print 'load test data... ',
    testRows = data.loadTestJson(testFile)
    print str(datetime.now() - dt)

    dt = datetime.now()
    print 'train model'
    m = StackModel(n_estimators, k, n)
    m.train(trainRows)
    print 'train model, done in %s' % str(datetime.now() - dt)

    m.estimator.n_jobs = 1

    dt = datetime.now()
    print 'generate submission'
    with open(outFile, 'w') as f:
        f.write('Insult,Date,Comment\n')
        f.writelines(('%f,%s,%s\n' % (m.classify1(row), row.dt, row.rawText)
                      for row in testRows))

    print 'generate submission, done in %s' % str(datetime.now() - dt)
Exemple #3
0
def makeSubmission(model, testFile, outFile):
  rows = loadTestJson(testFile)
  printNow("  load test rows")
  with open(outFile, 'w') as f:
    f.write('Insult,Date,Comment\n')
    f.writelines(['%f,%s,%s\n' % (model.classify1(row), row.dt, row.rawText) for row in rows])
    printNow("  submission created")
def makeSubmission(model, testFile, outFile):
    rows = loadTestJson(testFile)
    printNow("  load test rows")
    with open(outFile, 'w') as f:
        f.write('Insult,Date,Comment\n')
        f.writelines([
            '%f,%s,%s\n' % (model.classify1(row), row.dt, row.rawText)
            for row in rows
        ])
        printNow("  submission created")