1 Introduction
A precision–recall curve is a two-dimensional plot that summarizes how a binary classification model behaves as its decision rule is adjusted. Each point on the curve corresponds to choosing a particular threshold on the model’s output scores and then computing precision and recall for that threshold. The result shows how the balance between making correct positive predictions (precision) and finding as many true positives as possible (recall) changes when the model becomes more or less permissive.
1.1 Motivation and when it’s used
Precision–recall curves are particularly useful when the positive class is rare. In such settings, overall accuracy can appear high even for weak models because most examples are negative. Precision–recall analysis instead focuses directly on the quality of positive predictions and the ability to recover positive instances. This makes the approach common in domains such as fraud detection, anomaly detection, medical screening, and information retrieval, where the costs of missed positives or false alarms are often asymmetric.
1.2 Relationship to threshold-based classification
Many classifiers produce a score (often a probability-like quantity) for each example. A threshold converts scores into predicted labels: scores above the threshold are treated as positive, those below as negative. Changing the threshold alters the predicted set of positives, which in turn changes both precision and recall. The precision–recall curve captures this dependency across thresholds in a single visualization.
1.3 Precision and recall definitions
For a given threshold, predictions yield a confusion matrix with true positives (TP), false positives (FP), and false negatives (FN) relevant to precision and recall. Precision is defined as the fraction of predicted positives that are truly positive:
- Precision = TP / (TP + FP)
Recall is the fraction of actual positives that are correctly predicted as positive:
- Recall = TP / (TP + FN)
Both metrics depend on the chosen threshold and therefore can be traced as the threshold varies.
2 Constructing the Curve
Building a precision–recall curve typically requires either evaluating the model at many thresholds or, more commonly, sorting prediction scores and stepping through distinct score levels.
2.1 Computing precision and recall at a threshold
Given a threshold, one marks all examples with scores above the threshold as predicted positives. From TP, FP, and FN counts, precision and recall are computed directly using the formulas above. The pair (recall, precision) becomes one point on the curve. Repeating this procedure for multiple thresholds yields the full set of points.
2.2 Varying the decision threshold
A threshold sweep can be performed by trying all unique score values produced by the model (plus possibly one additional threshold that forces all predictions to be negative). As the threshold decreases, more items are labeled positive, generally increasing recall but potentially decreasing precision due to additional false positives. Conversely, increasing the threshold tends to raise precision while lowering recall.
2.3 Handling ranking scores and ties
Often, model outputs are treated as ranking scores rather than perfectly calibrated probabilities. When multiple examples share the same score (a tie), the curve must specify what happens as the threshold passes that shared value. Common approaches include:
- Treating the threshold as including all tied items together, so the curve has step changes rather than individual jumps.
- Defining interpolation rules that preserve consistency across tie-handling.
Because tie treatment affects the exact discrete points, reproducibility benefits from explicitly documenting the chosen rule.
2.4 Interpreting the axes
The x-axis typically shows recall, ranging from 0 to 1, representing coverage of the true positive set. The y-axis shows precision, ranging from 0 to 1, representing how trustworthy predicted positives are. A curve that rises toward higher precision at a given recall indicates a model that recovers positives while keeping false alarms relatively low.
2.5 Baseline and reference lines
A baseline reference helps interpret whether a model adds value beyond trivial prediction strategies. In the simplest case, a reference can be drawn at the precision expected if predictions were random while maintaining the same prevalence of the positive class. For an uninformative ranker, precision does not systematically improve as threshold changes, and the curve tends to remain near this baseline. The baseline depends on class prevalence rather than on any learned structure.
3 Area Under the Curve
To summarize a precision–recall curve with a single number, one can compute an area metric or an averaged score derived from precision values at different recall levels.
3.1 Average Precision (AP)
Average Precision is commonly used in practice and is closely tied to how the curve is computed from discrete thresholds. Intuitively, AP measures the average of precision values over recall improvements, weighting more informative parts of the curve where the model successfully finds additional positives. In many implementations, AP corresponds to summing precision at each recall step and accounting for how recall increases as more positive instances are captured.
3.2 Differences between AP and PR-AUC
Although AP and PR-AUC both summarize a precision–recall curve, they are not always identical. PR-AUC typically refers to the integral of precision with respect to recall under a specified interpolation scheme, producing a geometric area measure. AP, by contrast, often follows a definition aligned with ranking evaluation and can be computed using discrete recall steps with specific rules (such as using precision values at the points where new positives are found). With coarse sampling or different tie conventions, AP and PR-AUC can diverge.
3.3 Macro/micro averaging for multi-class settings
In multi-class classification, one typically evaluates one-vs-rest precision–recall curves for each class and then aggregates. Macro averaging treats each class as equally important by averaging per-class metrics, which highlights performance on rare classes. Micro averaging pools counts across classes before computing precision and recall, often reflecting overall performance weighted by frequency. The choice affects interpretation, especially under heavy class imbalance.
3.4 Interpreting AUPRC values
AUPRC (area under the precision–recall curve) and AP can be interpreted as “higher is better,” but their absolute values are influenced by prevalence. A model evaluated on a dataset with very few positives can achieve a modest AUPRC while still being practically useful, whereas a higher AUPRC on a more balanced dataset may not translate directly across datasets. Comparing models within the same dataset and evaluation protocol is usually most reliable.
4 Practical Considerations
Precision–recall behavior depends not only on the classifier but also on how scores are produced, how thresholds are selected, and how the data are sampled.
4.1 Class imbalance effects
When the positive class is rare, precision often drops quickly as the threshold lowers, because admitting more items increases the number of false positives dramatically. As a result, the curve may show a steep trade-off: small gains in recall can come with larger reductions in precision. This sensitivity is precisely why precision–recall analysis is preferred over accuracy in many imbalanced problems.
4.2 Calibration and score scaling
Precision–recall curves depend on the relative ordering of scores more than their absolute calibration, but threshold-based operating points still use the score scale. If scores are poorly calibrated, a chosen threshold may not correspond to the intended trade-off in another dataset. Calibration methods (such as monotonic transformations) can help align thresholds with observed outcomes, which can improve stability of precision–recall behavior when the score distribution shifts.
4.3 Threshold selection strategies
Selecting a threshold typically targets an application-specific operating point. Common strategies include:
- Choosing the threshold that maximizes a chosen metric (e.g., F1).
- Picking a threshold that meets a minimum precision requirement while maximizing recall.
- Selecting a threshold based on expected utility or constraints (for example, limiting false alarms).
The best choice depends on the relative costs of false positives and false negatives.
4.4 Cost-sensitive decision making
When errors have different costs, threshold selection can be framed as minimizing expected cost. Precision and recall can be linked to the rates of false positives and false negatives, which then map to cost terms. Even without a fully specified cost model, practitioners often select thresholds using a policy aligned with operational requirements, such as prioritizing high precision in alerting workflows or prioritizing high recall in screening pipelines.
4.5 Sampling effects and dataset size
Estimates of precision and recall become noisier with fewer positive examples. This affects the shape of the curve, especially in high-recall or low-threshold regions where fewer positives determine the achievable recall increments. Confidence intervals or repeated resampling can be helpful when comparing models, because apparent differences on small datasets may be driven by sampling variability.
5 Comparing Models with PR Curves
Precision–recall curves are often used to compare models and to understand which regions of the trade-off each model optimizes.
5.1 Visual comparison techniques
A common approach is to compare curves directly: if one curve consistently lies above another across recall levels, it indicates dominance under the evaluated threshold sweep. However, dominance is not always complete. When curves cross, one model may be preferable for specific recall targets while the other excels elsewhere. In such cases, selecting operating points aligned with the application’s recall/precision requirements clarifies the comparison.
5.2 Statistical considerations in comparison
Curve differences can be evaluated statistically using resampling-based methods (e.g., bootstrapping) or tests aligned with ranking metrics. Such methods account for sampling variability in TP, FP, and FN counts, helping distinguish genuine performance gaps from random fluctuations, particularly when positive counts are limited.
5.3 Selecting a common evaluation protocol
Comparisons should be performed using consistent preprocessing steps, the same train/validation split strategy, identical threshold evaluation logic, and the same handling of ties and averaging conventions. Inconsistencies can shift the curve in ways unrelated to model quality. Reproducible protocols are essential for fair model comparison.
5.4 Sensitivity to hyperparameters
Model hyperparameters can affect score distributions and ranking quality. Regularization strength, class weighting, early stopping criteria, and feature engineering choices can all alter how precision and recall trade off. When comparing models, it is often informative to examine whether a change improves the curve uniformly or only in narrow regions, which may indicate overfitting to a particular threshold behavior rather than robust ranking.
6 Special Cases and Edge Behaviors
Certain idealized or extreme scenarios produce characteristic precision–recall shapes that help interpret results.
6.1 Perfect classifier behavior
A perfect classifier ranks all positives above all negatives. In such a case, increasing recall from 0 to 1 can be done without introducing false positives, so precision remains at 1 across recall levels until full recall is reached. The curve reaches the top of the plot before moving to recall=1.
6.2 Random/uninformative classifier behavior
An uninformative classifier effectively produces scores independent of the true label. As thresholds vary, the predicted positives behave like random samples from the dataset. Under randomness, precision tends to align with the positive class prevalence, yielding a curve that stays near a horizontal baseline rather than improving as recall increases.
6.3 Extreme threshold regimes
At very high thresholds, the model may predict only a few positives, sometimes none. When no predicted positives occur, precision can be undefined; many tools define it as 1 or 0 depending on convention, or they omit that point. At very low thresholds, nearly everything may be predicted positive, pushing recall toward 1 while precision collapses toward the prevalence level.
6.4 Small positive-class scenarios
When there are very few positives, the curve consists of only a handful of steps corresponding to finding each additional positive instance. This can yield a jagged or coarse curve, and summary statistics like AP may have high variance. Interpretation should therefore consider uncertainty and possibly confidence intervals, especially if the goal is to compare closely performing models.
7 Variants and Related Tools
Precision–recall curves are part of a broader family of evaluation tools focused on ranking and trade-offs between positive predictive value and coverage.
7.1 ROC curve vs precision–recall curve
The ROC curve plots true positive rate against false positive rate. While it is useful in many settings, it can be overly optimistic when the positive class is rare because false positive rate can remain low even when the number of false positives is large in absolute terms. Precision–recall curves address this by directly measuring the correctness of predicted positives, often making them more informative under imbalance.
7.2 F1 score and iso-F1 curves
The F1 score combines precision and recall through the harmonic mean:
- F1 = 2 * (precision * recall) / (precision + recall)
On the precision–recall plane, iso-F1 lines represent points that yield the same F1 value. One can use these lines to understand where a chosen balance between precision and recall occurs and to select thresholds that maximize F1.
7.3 Precision at k and recall at k
In some tasks, predictions are evaluated by taking only the top-k ranked items. Precision@k measures the fraction of true positives among those k items, and recall@k measures the fraction of all true positives that appear in the top k. These metrics are closely aligned with the ranking perspective and can be more stable in scenarios where only a limited number of results are operationally actionable.
7.4 PR curves in information retrieval
Information retrieval often evaluates ranked lists of items returned to a user. Precision–recall curves adapt naturally to this context by treating relevant documents as the positive class and score-based ranking as the basis for thresholds. As recall increases, the curve shows how retrieval quality evolves as more results are included.
7.5 Micro- vs macro-averaged PR curves
Micro-averaged curves compute precision and recall by pooling decisions across all classes, effectively weighting frequent classes more heavily. Macro-averaged curves or metrics evaluate each class separately and then average, giving equal influence to each class regardless of prevalence. The choice depends on whether the objective is to optimize overall performance or ensure minimum quality across all classes.
8 Reporting and Best Practices
Good reporting practices improve interpretability, enable fair comparisons, and reduce the risk of misreading results.
8.1 Choosing metrics to report
Common reports include AP or PR-AUC, along with the full precision–recall curve. For operational decisions, reporting precision at targeted recall levels (or recall at targeted precision) can be more actionable than reporting a single averaged number. The metric choice should match the intended use case and the decision constraints.
8.2 Cross-validation and holdout evaluation
Evaluation should be conducted on data not used for training, typically via a holdout test set or cross-validation. When cross-validation is used, curves and metrics can be averaged across folds, and variability can be reported. This helps confirm that observed improvements are not artifacts of a particular split.
8.3 Reproducibility and implementation details
Reproducibility requires specifying how thresholds are generated (all unique scores vs fixed grid), how ties are resolved, and which averaging method is used for multi-class problems. Libraries may use slightly different definitions for AP and curve interpolation, so documenting the implementation or reporting the metric definition helps avoid confusion.
8.4 Common pitfalls and misinterpretations
Several pitfalls recur in practice:
- Comparing PR curves from different preprocessing or evaluation protocols.
- Treating AP values as directly comparable across datasets with different positive prevalence.
- Ignoring uncertainty on small datasets, where the curve may fluctuate due to limited positive examples.
- Selecting thresholds on the test set rather than using validation, which can lead to optimistic performance claims.
Careful evaluation design mitigates these issues and supports sound conclusions.