All problems
ROC Curve Points
Problem
Compute ROC curve points for binary labels. Start at [0.0, 0.0] (threshold above every score), then for each unique score in descending order predict positive when score >= threshold and append [FPR, TPR].
If there are no positive or no negative labels, the corresponding rate is 0.0. Empty input returns [].
Hint
Sweep the unique scores from high to low and track cumulative TP and FP fractions.
Test cases
case 1
in: [[0,0,1,1],[0.1,0.4,0.35,0.8]]
expected: [[0,0],[0,0.5],[0.5,0.5],[0.5,1],[1,1]]
case 2
in: [[1,1,0,0],[0.9,0.8,0.4,0.1]]
expected: [[0,0],[0,0.5],[0,1],[0.5,1],[1,1]]
case 3
in: [[1,1],[0.5,0.5]]
expected: [[0,0],[0,1]]
case 4
in: [[],[]]
expected: []
Starter codePython
def roc_curve_points(y_true, scores):
# Your code here
pass4 test cases · run your code against them in the editor