Precision-Recall Curve
Precision-recall curve plots precision against recall across thresholds, showing model performance and the tradeoff between false alarms and missed cases.
A precision-recall curve is a graph showing how a model's precision and recall change as its decision threshold varies. Recall runs along the horizontal axis, and precision runs along the vertical axis. Each measured operating point comes from a threshold: how many positive cases the model finds and how trustworthy its positive predictions are. The curve helps evaluate classifiers and detectors when false alarms and missed cases carry different costs.
How a Precision-Recall Curve Works#
Precision is the fraction of positive predictions that are correct: TP / (TP + FP). Recall, also called sensitivity, is the fraction of actual positives found: TP / (TP + FN). TP means true positives, FP means false positives, and FN means false negatives—the outcomes counted in a confusion matrix.
Sweeping a confidence threshold across prediction scores produces precision-recall pairs. Lowering the threshold admits more predictions, so recall increases or stays unchanged. Precision can move in either direction as correct and incorrect predictions enter the set, producing a staircase-shaped curve.
Cyril Cleverdon introduced recall-versus-relevancy plots in his 1962 Cranfield report, establishing the information-retrieval roots of precision-recall evaluation. In document search, relevant retrieved documents are true positives; irrelevant retrieved documents are false positives.
Interpreting the Curve and Its Baseline#
A curve that maintains high precision as recall approaches 1 indicates strong performance. When curves cross, each model performs better in a different operating region. A sharp precision drop shows where additional predictions introduce many false alarms.
The baseline for an uninformative random ranking is positive-class prevalence—the fraction of examples labeled positive. With 1% positives, baseline precision is 0.01. Changing prevalence changes precision, making the evaluation population part of the result.
A receiver operating characteristic (ROC) curve instead plots recall against false-positive rate, FP / (FP + TN), where TN means true negatives. Precision-recall evaluation directly expresses the share of alerts that are correct, making it useful for rare positives. Accuracy can be dominated by the majority class.
Choosing an Operating Threshold#
Select an operating point on validation data according to error costs. For a required minimum recall, select the feasible point with highest precision; for minimum precision, select the feasible point with highest recall. Maximizing the F1-score, the harmonic mean of precision and recall, gives both metrics equal weight. Threshold values come from underlying scores or precision-confidence and recall-confidence plots.
Ultralytics YOLO prediction exposes this choice through conf, which filters scored detections. In an Academy evaluation of YOLO26n on four COCO8 validation images at IoU 0.50, raising conf from 0.10 to 0.25 changed interpolated person-class precision/recall from 0.63/0.80 to 1.00/0.54: fewer false alarms came with more missed people.
Keep the selected threshold fixed when evaluating separate test data.
Plotting a Precision-Recall Curve in Python#
This example distinguishes handwritten digit 9 from other digits using bundled images and logistic regression. Install dependencies with pip install scikit-learn matplotlib, then use scikit-learn's precision-recall plotting API.
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import PrecisionRecallDisplay
from sklearn.model_selection import train_test_split
X, digits = load_digits(return_X_y=True)
y = digits == 9
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=42)
model = LogisticRegression(max_iter=2000)
model.fit(X_train, y_train)
PrecisionRecallDisplay.from_estimator(model, X_test, y_test)
plt.savefig("precision_recall_curve.png", bbox_inches="tight")The saved plot shows precision at each attainable recall level for held-out digit images.
Object Detection and Average Precision#
In object detection, a predicted bounding box counts as a true positive when it matches an unclaimed annotated object of the same class at or above the intersection over union (IoU) threshold. Unmatched predictions, including duplicates, count as false positives. Each class has a separate curve with the IoU requirement fixed.
Average precision (AP) summarizes the curve across recall levels. Trapezoidal PR-AUC and noninterpolated AP use different integration rules. Mean average precision (mAP) averages class AP values. In detection performance metrics, mAP50 uses IoU 0.50, while mAP50–95 averages over ten IoU thresholds from 0.50 through 0.95 in increments of 0.05.










