Skip to content

Instantly share code, notes, and snippets.

@bryanyang0528
Created June 23, 2015 06:26
Show Gist options
  • Save bryanyang0528/5d8fef617fae187030ed to your computer and use it in GitHub Desktop.
Save bryanyang0528/5d8fef617fae187030ed to your computer and use it in GitHub Desktop.
ROC CURVE
def roc(pred, actual):
roc=[]
p=float(len(actual)-sum(actual))
n=float(sum(actual))
for i in range(0,100,1) :
TP=0
FP=0
i = float(i)/100
for j in range(len(pred)):
if (pred[j] > i) & (actual[j]==0):
TP+=1
if (pred[j] > i) & (actual[j]==1):
FP+=1
roc.append((TP/p,FP/n))
return roc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment