ROC-AUC computation
Your task
Given y_true (binary labels 0/1) and scores (real-valued classifier scores, higher means more likely positive), compute the ROC-AUC using the trapezoidal rule over thresholds. Sort the unique candidate thresholds, and for each, classify a point as positive when score >= threshold. Build the ROC curve as (FPR, TPR) points including the endpoints (0,0) and (1,1), sort by FPR ascending (breaking ties by TPR), and integrate the area under the curve with the trapezoidal rule. Return the AUC rounded to 4 decimal places. There is at least one positive and one negative label; length up to 2000.
Examples
roc_auc(y_true: list[int], scores: list[float]) -> floatExample 1
Input
roc_auc([1, 1, 0, 0], [0.9, 0.6, 0.4, 0.1])Output
1