Skip to content

Instantly share code, notes, and snippets.

@choupi
Created February 26, 2016 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choupi/93218424d192e8a91369 to your computer and use it in GitHub Desktop.
Save choupi/93218424d192e8a91369 to your computer and use it in GitHub Desktop.
import sys
import csv
import math
from sklearn import metrics
EPS=1e-15
rd=[]
y=[]
with open(sys.argv[1], 'rb') as f:
for sl in csv.reader(f):
if len(sl)<4: continue
rd.append(float(sl[2]))
y.append(int(sl[3]))
fpr, tpr, thresholds = metrics.roc_curve(y, rd)
#print fpr
#print tpr
#print thresholds
print metrics.auc(fpr, tpr)
with open(sys.argv[2], 'wb') as f:
f.write('0 0\n')
for i in xrange(len(fpr)):
f.write('%.8f %.8f\n'%(fpr[i], tpr[i]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment