Calculate the area under the precision-recall curve for imbalanced classification.
The Precision-Recall (PR) curve plots precision against recall across classification thresholds, and the area under it (PR-AUC, closely related to Average Precision) summarizes performance in a single number focused on the positive class. Unlike ROC-AUC, PR-AUC is highly sensitive to class imbalance in a useful way — because precision is influenced by how rare the positive class is, PR-AUC drops noticeably for models that struggle to find a rare positive class, making it a preferred metric for imbalanced problems like fraud or anomaly detection.
PR-AUC = sum((Precision_i + Precision_{i+1}) / 2 * (Recall_{i+1} - Recall_i))
ROC-AUC can look deceptively good on imbalanced datasets because the false positive rate denominator is dominated by the large negative class, while PR-AUC's precision term is directly affected by how many false positives occur relative to true positives, better reflecting real-world performance on the rare class.
A PR-AUC roughly equal to the fraction of positive examples in the dataset indicates the model provides little discriminative value over a random classifier — a useful baseline to compare against.
They're closely related and often used interchangeably; Average Precision is typically computed as a weighted sum over precision values at each recall level achieved by actual predictions, which is numerically similar to trapezoidal integration of the PR curve.