Carlos-Francisco Méndez-Cruz

Conditional Random Fields

......@@ -235,13 +235,10 @@ if __name__ == "__main__":
nameReport = options.trainingFile.replace('.txt', '.fStopWords_' + str(options.excludeStopWords) + '.fSymbols_' + str(
options.excludeSymbols) + '.txt')
with open(os.path.join(options.outputPath, "reports", "report_" + nameReport), mode="w") as oFile:
oFile.write("********** TRAINING AND TESTING REPORT **********\n")
oFile.write("********** TRAINING **********\n")
oFile.write("Training file: " + options.trainingFile + '\n')
oFile.write('\n')
oFile.write("Model: {}".format(crf))
#oFile.write('best params:' + str(crf.best_params_) + '\n')
#oFile.write('best CV score:' + str(crf.best_score_) + '\n')
#oFile.write('model size: {:0.2f}M\n'.format(crf.best_estimator_.size_ / 1000000))
print("Training done in: %fs" % (time() - t0))
t0 = time()
......@@ -276,7 +273,7 @@ if __name__ == "__main__":
# labels.remove('O')
with open(os.path.join(options.outputPath, "reports", "report_" + nameReport), mode="a") as oFile:
oFile.write('\n')
oFile.write('********** EVALUATION **********\n')
oFile.write("Flat F1: " + str(metrics.flat_f1_score(y_test, y_pred, average='weighted', labels=labels)))
oFile.write('\n')
# labels = list(crf.classes_)
......