Given FPR and TPR arrays from a ROC curve, compute the AUC (Area Under Curve) using the trapezoidal rule.
The AUC provides a single scalar metric that summarizes the performance of a binary classifier across all classification thresholds. It represents the probability that the classifier will rank a randomly chosen positive instance higher than a randomly chosen negative instance.
AUC Formula:
AUC=∫01TPR(FPR)dFPRApproximated using the trapezoidal rule:
AUC≈i=1∑n−121(TPRi+TPRi+1)(FPRi+1−FPRi)fpr: array-like, shape (M,) - False Positive Rate values (increasing)tpr: array-like, shape (M,) - True Positive Rate values (same length as fpr)Input: fpr=[0,0,1], tpr=[0,1,1]
Output: 1.0
Input: fpr=[0,1], tpr=[0,1]
Output: 0.5
Use np.trapezoid() for trapezoidal integration.
Validate that fpr and tpr have the same length and at least 2 points.
The result should be a scalar float, not an array.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Given FPR and TPR arrays from a ROC curve, compute the AUC (Area Under Curve) using the trapezoidal rule.
The AUC provides a single scalar metric that summarizes the performance of a binary classifier across all classification thresholds. It represents the probability that the classifier will rank a randomly chosen positive instance higher than a randomly chosen negative instance.
AUC Formula:
AUC=∫01TPR(FPR)dFPRApproximated using the trapezoidal rule:
AUC≈i=1∑n−121(TPRi+TPRi+1)(FPRi+1−FPRi)fpr: array-like, shape (M,) - False Positive Rate values (increasing)tpr: array-like, shape (M,) - True Positive Rate values (same length as fpr)Input: fpr=[0,0,1], tpr=[0,1,1]
Output: 1.0
Input: fpr=[0,1], tpr=[0,1]
Output: 0.5
Use np.trapezoid() for trapezoidal integration.
Validate that fpr and tpr have the same length and at least 2 points.
The result should be a scalar float, not an array.
Sign in to take notes on this problem
Accepts: array
Accepts: array