#NEWLINE# def roc( tests = [ ] ) : #NEWLINE# #INDENT# ' Returns the ROC curve as an iterator of (x, y)-points,\n        for the given list of (TP, TN, FP, FN)-tuples.\n        The x-axis represents FPR = the false positive rate (1 - specificity).\n        The y-axis represents TPR = the true positive rate.\n    ' #NEWLINE# x = FPR = ( lambda TP , TN , FP , FN : ( float ( FP ) / ( ( FP + TN ) or 1 ) ) ) #NEWLINE# y = TPR = ( lambda TP , TN , FP , FN : ( float ( TP ) / ( ( TP + FN ) or 1 ) ) ) #NEWLINE# return sorted ( ( [ ( 0.0 , 0.0 ) , ( 1.0 , 1.0 ) ] + [ ( x ( * m ) , y ( * m ) ) for m in y ] ) )