All problems
PR AUC Trapezoid
Problem
Compute the area under a precision-recall curve with the trapezoidal rule. For each distinct recall keep the maximum precision, sort by recall, and sum (r1 - r0) * (p0 + p1) / 2.
Return 0.0 with fewer than two distinct recall values.
Hint
Keeping one precision per recall first removes vertical segments from the curve.
Test cases
case 1
in: [[[1,0.5],[0.5,0.5],[0.6666666666666666,1],[0.5,1]]]
expected: 0.41666666666666663
case 2
in: [[[1,1]]]
expected: 0
case 3
in: [[[0.9,0.2],[0.7,0.5],[0.5,1]]]
expected: 0.54
case 4
in: [[]]
expected: 0
Starter codePython
def pr_auc_trapezoid(pr_points):
# Your code here
pass4 test cases · run your code against them in the editor