For imbalanced problems (fraud, rare disease, retrieval), ROC AUC can look great while the model is useless at the top of the ranking. The precision-recall curve and average precision (AP) focus on the positives.
Sort predictions by score, highest first. Treat each distinct score as a threshold: everything at or above it counts as predicted positive. At each threshold, compute precision and recall. Then
over thresholds in order, with . (This is scikit-learn's average_precision_score.)
Implement pr_curve(y_true, scores) returning (precisions, recalls, thresholds) in that order (highest threshold first), and average_precision(y_true, scores). Return nan if there are no positives.