Skip to content

Instantly share code, notes, and snippets.

@kindleton
Created April 15, 2016 01:49
Show Gist options
  • Save kindleton/57c4113118636d42d202c3f15dd075f9 to your computer and use it in GitHub Desktop.
Save kindleton/57c4113118636d42d202c3f15dd075f9 to your computer and use it in GitHub Desktop.
import sys
from sklearn.metrics import classification_report
if len(sys.argv) < 2 :
print "Usage : python code.py pairFile"
sys.exit(1)
#pair file means, a file with (actual label, predicted label) pairs
pairFile = open(sys.argv[1],'r+')
report = open('report.txt','w')
y_true , y_pred , labels = [], [], []
for line in pairFile:
line = line.split()
if len(line) == 2 :
y_true.append(line[0])
y_pred.append(line[1])
pairFile.close()
report.write(classification_report(y_true, y_pred))
print >> sys.stderr, "Output written to report.txt"
report.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment