Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

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.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning