AI Glossary / Causal inference and experimentation / Intermediate
Precision-recall curve
Definition
A precision-recall curve shows how a classifier's precision and recall change as its decision threshold varies. Recall is usually plotted on the horizontal axis and precision on the vertical axis. Each operating point describes both the fraction of actual positives found and the fraction of positive predictions that are correct. The curve helps examine the trade-off between finding more target cases and keeping the selected results useful.
What it means
A classifier often assigns a score before a threshold turns that score into a yes-or-no decision. A strict threshold may select only a few high-scoring examples. A looser threshold includes more examples, potentially finding additional positives but also admitting more false positives.
One accuracy score hides these alternative operating choices. A precision-recall curve makes them visible and can be especially informative when the positive condition is uncommon and the quality of alerts matters.
The curve does not choose the right threshold by itself. That decision depends on missed-case consequences, review capacity, and the value of correct detections. It also does not establish whether score values are well-calibrated probabilities.
How it works
Collect a score and a reference binary label for every evaluation example. Choose a positive class and a consistent threshold rule. At each distinct threshold, count true positives, false positives, and false negatives.
Calculate precision as TP/(TP + FP) and recall as TP/(TP + FN), then plot the pair. When a threshold is lowered, the selected set expands, so recall cannot decrease on the fixed dataset. Precision may move up or down depending on which examples enter; empirical curves can therefore look jagged.
Handle tied scores together according to the threshold rule and document endpoint conventions. With no predicted positives, precision's ordinary ratio is undefined, though plotting software may add a conventional endpoint. Compare curves on the same representative data, and keep threshold selection separate from final performance assessment where appropriate.
Three practical examples
1. Support escalation: a team examines how many urgent requests it can detect while maintaining an acceptable proportion of useful alerts for reviewers.
2. Document retrieval: developers compare how result relevance changes as the system retrieves more of the available relevant documents.
3. Defect screening: inspectors study threshold options that balance missed defective items with the number of ordinary items sent for extra inspection.
Think of it this way
Think of widening a net and checking both how many desired objects it catches and how much unwanted material enters. A wider net can increase coverage without guaranteeing cleaner contents. The analogy is limited because model thresholds operate on scores, not physical size, and some added groups can be more relevant than others. The curve describes observed decisions, not an unavoidable smooth law of trade-offs.
Worked example
Suppose six fictional cases have descending scores 0.95, 0.85, 0.70, 0.55, 0.40, and 0.20. Their actual labels are positive, negative, positive, positive, negative, and negative. There are three actual positives. Predict positive when the score is at least the threshold.
At threshold 0.95, only one case is selected. Precision is 1/1 = 1 and recall is 1/3. At 0.85, two are selected, giving precision 1/2 and recall 1/3. At 0.70, two of three selected cases are positive, giving precision 2/3 and recall 2/3.
At 0.55, three of four are positive, so precision is 3/4 and recall is 1. At 0.20, all six are selected, giving precision 3/6 = 1/2 and recall 1. The example shows why precision can improve when the threshold is lowered: moving from 0.85 to 0.70 adds a true positive. It also shows that different thresholds can have the same recall but different precision and workload.
Illustrative case study
Fictional case: Elm Repairs compares two alerting models. One has a better summary score across its full precision-recall curve, but the other provides cleaner alerts in the high-recall region that the team's inspection policy requires.
The analysts show the curves with candidate thresholds and estimated alert counts, then evaluate the selected operating point on a separate assessment set. They explain that the preferred choice depends on the intended operating region, not only the largest overall summary. This illustrates decision-focused evaluation and does not report a real model competition or deployment result.
Common misconceptions and mistakes
Do not assume precision must decline at every increase in recall. Finite ranked data can create upward and downward steps. Nor is a curve made from already thresholded class labels equivalent to one made from the underlying scores; the latter exposes many more operating choices.
Average precision and trapezoidal area under a precision-recall curve are not universally identical. Their interpolation and aggregation conventions differ, so name the summary being reported. A high summary can still hide weak performance in a particular operating region.
The curve depends on class prevalence and case mix. Comparing curves built from differently sampled populations can be misleading. Also inspect small sample counts and uncertainty, especially near strict thresholds that select very few examples.
Business use
A precision-recall curve can turn a technical model comparison into an operational conversation about coverage and review effort. Label relevant thresholds and show the expected number of alerts for the evaluated population.
Use the curve together with costs, capacity, and subgroup checks. Record whether the evaluation sample reflects the deployment prevalence. If operations change, reassess the chosen threshold rather than assuming the old precision will persist. The curve is most useful when tied to a concrete decision and a clearly defined positive condition.
People also ask
Why does predicting everything positive give recall one?
Every actual positive is selected. Precision then equals the positive fraction of the evaluated dataset.
Does the curve require probability estimates?
No. Ranking scores can be used, provided their direction and threshold interpretation are clear.
Can a precision-recall curve be used for multiclass problems?
A class can be evaluated against the rest, with any cross-class averaging explicitly defined. The basic construction is binary.
Check your understanding
A threshold selects ten cases, including eight true positives, from a dataset with twenty actual positives. What point appears on the usual precision-recall plot?
Answer: Recall is 8/20 = 0.40 and precision is 8/10 = 0.80, so the point is (0.40, 0.80) when recall is the horizontal axis.
Related terms
- Precision
- Recall
- Threshold (for decision trees)
- ROC (receiver operating characteristic) Curve
- Positive class
- Confusion matrix
- threshold
- average precision
- ROC curve
- class imbalance
Learn next
Rank eight labeled examples by score and calculate precision and recall after each tied-score group enters. Mark two thresholds with different workloads, then explain which additional business information is needed to choose between them.
More in Causal inference and experimentation
- Policy evaluation - Policy evaluation is the task of estimating how much future reward an agent can expect when it follows a specified policy.
- Post-sample evaluation - Post-sample evaluation assesses a forecasting model using observations from after the period on which it was estimated.
- Precision at k (precision@k) - Precision at k, written precision@k or P@k, is the fraction of the first k items in a ranked result list that are relevant.
- Preferential Bayesian optimization - Preferential Bayesian optimization is a sequential search method that uses comparisons between alternatives to seek a preferred solution.
- Probabilistic Programming - Probabilistic programming is an approach to expressing statistical models as programs that represent uncertainty through probability distributions.
- Propensity scores - Propensity scores are the probabilities of receiving a particular treatment or exposure conditional on observed pretreatment characteristics.
Sources
Scikit-learn, precision_recall_curve documentation: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html
Google, Machine Learning Glossary, precision-recall curve: https://developers.google.com/machine-learning/glossary#precision-recall-curve
The primary references support the threshold-based construction and endpoint conventions. The worked list, fictional case, and exercise are original teaching material.
Previous: Precision at k (precision@k) Next: Precomputation