def run_test(train_in, train_out, test_in, test_out, modelname, embeddings, run_parse=True,
model_type='logreg',C=10.0,
alpha=1.0, cutoff=0.50, n_iter=1):
# test performance of model against a hand classified test set
# running the parser takes most of the time right now, so option to shut it off
run_cat(train_in,modelname,train_out,embeddings,new_run=True,run_parse=run_parse,
model_type=model_type,C=C,
alpha=alpha, cutoff=cutoff, n_iter=n_iter)
run_cat(test_in,modelname,test_out,embeddings,new_run=False,
model_type=model_type,C=C,
alpha=alpha, cutoff=cutoff, n_iter=n_iter)
testData = pd.read_csv(test_out)
precision = metrics.precision_score(testData.truth, testData.category, average='weighted')
print "Overall precision is " + str(precision*100.) + "%"
return precision
评论列表
文章目录