Precision-recall curve

Also known as: PR curve

On this page 7

A precision-recall curve, or PR curve, is a plot of a binary classifier’s precision on the vertical axis against its recall on the horizontal axis as the decision threshold sweeps from the strictest to the most permissive setting. In model evaluation it is the preferred diagnostic when the positive class is rare, because it focuses entirely on how well a model finds and correctly labels the cases that matter.

Each point on the curve corresponds to one threshold applied to the model’s scores. The curve therefore summarizes every possible operating point in one picture and lets practitioners choose the threshold that matches the real cost of false alarms versus missed cases.

How a precision-recall curve is constructed

A precision-recall curve is built by ranking predictions by score and computing precision and recall at each candidate threshold. Precision is TP / (TP + FP), the share of predicted positives that are correct. Recall is TP / (TP + FN), the share of actual positives that the model finds.

  1. Score every example in the evaluation dataset with the model’s probability or confidence output.
  2. Sort examples by descending score.
  3. Treat each distinct score as a threshold and count true positives, false positives and false negatives above it.
  4. Plot the resulting recall and precision pairs and connect them in order of decreasing threshold.

Lowering the threshold can only raise or hold recall, but precision may rise or fall, so the raw curve is not monotonic and often looks jagged near low recall. Many tools report an interpolated curve, where precision at each recall is replaced by the maximum precision at any higher recall.

The table below shows how individual points on the curve relate to threshold choices.

RegionThresholdTypical behavior
Left edgeVery highFew predictions, precision often high but unstable
Upper-right cornerIdeal balanceHigh precision and high recall together
Right edgeVery lowRecall near 1, precision falls toward prevalence
Knee of the curveModeratePoint where precision starts to drop sharply
Regions of a precision-recall curve

Summary metrics derived from the curve

The curve is often condensed into a single number so that models can be ranked, though each summary hides part of the trade-off. Average precision (AP) is the most common: it is the weighted mean of precision at each threshold, with the recall increase as the weight, and it approximates the area under the PR curve (AUPRC).

MetricDefinitionWhen it is useful
Average precisionStep-wise sum of precision × recall changeRanking models on rare-event tasks
AUPRC (trapezoidal)Area via linear interpolationRarely preferred; can be optimistic
Best F1 scoreMaximum harmonic mean on the curveChoosing a balanced threshold
Precision at fixed recallPrecision where recall reaches a targetSafety or screening requirements
Mean average precisionAverage of AP over classes or queriesObject detection and retrieval
Scalar summaries of a precision-recall curve

An important caution is that linear interpolation between PR points is invalid because precision does not change linearly with recall. Trapezoidal areas can therefore overstate performance, which is why most libraries compute AP with a step function instead.

Precision-recall curve versus ROC curve

The PR curve and the ROC curve are built from the same predictions but answer different questions. The ROC curve plots the true positive rate against the false positive rate, which divides false positives by the large number of negatives, so it changes little when negatives are abundant.

The PR curve uses precision instead, which compares false positives with true positives. When positives make up 1% or less of the data, a model can show an ROC AUC above 0.95 while its precision stays low, and only the PR curve exposes that gap.

AspectPrecision-recall curveROC curve
AxesPrecision vs recallTrue positive rate vs false positive rate
Random baselineHorizontal line at class prevalenceDiagonal line, AUC 0.5
Sensitivity to imbalanceHigh; reflects rare positivesLow; dominated by negatives
Uses true negativesNoYes
Best fitFraud, retrieval, medical screeningBalanced classes, ranking quality
Comparison of PR and ROC analysis

A one-to-one mapping exists between the two curves for a given dataset, and a model that dominates in ROC space also dominates in PR space. The curves differ in emphasis, not in the underlying ranking information.

Reading the curve to choose a threshold

Choosing an operating point means translating error costs into a position on the curve. A model never ships as a curve; it ships with one threshold, and the curve shows what each choice will cost.

ApplicationPriorityTypical operating point
Cancer screeningMissed cases are costlyRecall of 0.95 or higher
Spam filteringFalse alarms annoy usersPrecision of 0.99 or higher
Fraud review queueAnalyst capacity is limitedPrecision matching queue size
Content moderation triageBalance of both errorsNear the maximum F1 point
Threshold strategies by application

The threshold should be chosen on a validation set and confirmed on a separate test set. Picking it on test data inflates the reported precision and recall through selection bias.

Limitations and common misreadings

The PR curve is powerful but easy to misread, and several pitfalls recur in practice.

  • Prevalence dependence: AP values cannot be compared across datasets with different positive rates, because the random baseline equals the prevalence.
  • Noisy low-recall region: with few predictions, a single error moves precision dramatically, so the left edge should not drive conclusions.
  • Small test sets: with only dozens of positives, AP has wide confidence intervals; bootstrapping helps quantify that uncertainty.
  • Calibration is invisible: the curve depends only on ranking, so a well-ranked model can still output poorly calibrated probabilities.
  • Distribution shift: a threshold tuned on historical data may land at a very different point if the positive rate changes in production.

For multiclass problems, curves are drawn one-versus-rest per class and averaged as macro or micro AP. Reporting the per-class curves alongside the average is good practice, because averages can hide a class with poor performance.

Put simply

Think of a metal detector on a beach. Set it to beep only at strong signals and nearly every beep is real treasure, but much treasure is missed. Set it to beep at everything and almost no treasure is missed, but most beeps are bottle caps. The precision-recall curve draws every possible setting of that sensitivity dial in one picture.

Precision answers how many beeps were worth digging for. Recall answers how much of the buried treasure was found. The best model is the one whose curve stays high toward the right, finding most treasure without many false beeps.

In practice

A data science team at a payment processor builds a model to flag fraudulent card transactions, which make up about 0.2% of all transactions. The model scores an ROC AUC of 0.97, which looks excellent, but the team plots the precision-recall curve on a held-out month of data and finds an average precision of 0.41.

The fraud operations unit can review about 2,000 alerts per day out of roughly one million transactions. Reading the curve, the team picks the threshold where precision reaches 0.60 at a recall of 0.55, which produces a daily alert volume close to that capacity. After retraining with additional merchant features, the curve shifts upward, and at the same alert volume recall rises to 0.68, catching substantially more fraud with no extra analyst workload.