Created
April 15, 2016 01:49
-
-
Save kindleton/57c4113118636d42d202c3f15dd075f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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