Confidence
A confidence score is a model's 0-to-1 estimate that a prediction is correct. How detectors compute it, how thresholds work, and why calibration matters.
A confidence score is the number between 0 and 1 that a model attaches to a prediction to express how likely that prediction is to be correct. Classifiers attach one to each class label, and object detection models attach one to each bounding box, where it answers a narrower question: how likely is it that this box contains an object of this class? Applications use confidence to decide which predictions to keep, in what order to rank them, and which ones to send to a person for review.
How Models Produce Confidence#
Confidence comes from the network's final layer. A single-label classifier passes its raw outputs, called logits, through softmax, which makes the class scores sum to 1, and reports the top value. Detectors usually apply a sigmoid to each class independently, so one box can score high for two related classes and the scores need not sum to 1. Detectors with a separate objectness output, such as YOLOv5, multiplied it by the class probability. Many anchor-free detectors, including recent YOLO models, drop objectness and use the highest class score as the box's confidence.
Confidence Thresholds#
A confidence threshold turns scores into decisions: predictions above it are kept and the rest are discarded. Raising the threshold removes false positives and raises precision. Lowering it recovers faint, small, or partly hidden objects and raises recall, at the cost of more false alarms. The threshold where the F1-score curve peaks balances the two. YOLO26 keeps boxes scoring above 0.25 at prediction time by default, and validation lowers the threshold to 0.001 so that its precision-recall curves cover nearly every possible operating point.
from ultralytics import YOLO
# Load a pretrained YOLO26 nano detector
model = YOLO("yolo26n.pt")
image = "https://ultralytics.com/images/bus.jpg"
# Run the same image at a low and a high confidence threshold
for threshold in (0.1, 0.6):
results = model(image, conf=threshold)
scores = results[0].boxes.conf.tolist()
print(f"conf={threshold}: {len(scores)} boxes, scores {[round(s, 2) for s in scores]}")The 0.1 run returns every box from the 0.6 run plus any weaker candidates, so raising the threshold only ever removes detections, starting with the least certain.
Using Confidence in Applications#
Many systems use two thresholds. Predictions below a low bar are discarded, predictions above a high bar trigger automatic action, and the band in between goes to a person, a second model, or another sensor. A medical screening tool can flag high-confidence findings at once and queue uncertain ones for a radiologist, and an active learning loop sends the uncertain band to annotators, a strategy called uncertainty sampling.
Confidence and Calibration#
A score of 0.9 is a usable probability only if the model is calibrated, meaning that among all predictions scored 0.9, about 90% are correct. Modern deep networks tend to be overconfident, with scores that run above their real hit rate. Temperature scaling corrects much of this by dividing the logits by one constant fitted on held-out data, and scikit-learn's calibration tools fit Platt (sigmoid) or isotonic mappings and plot reliability curves. Calibration matters whenever a score is read as a probability, such as a risk cutoff. Ranking metrics such as mean average precision (mAP) depend only on the order of the scores.
Confidence vs. Related Terms#
- Accuracy: a dataset-level rate of correct predictions. In a calibrated model, average confidence equals accuracy.
- Statistical confidence intervals: a separate idea that shares the name. A 95% confidence level describes how often an interval-building procedure captures a true value across repeated samples.
- Conformal prediction: turns raw scores into prediction sets with a coverage guarantee, so that for a 90% target the set contains the true label at least 90% of the time on exchangeable data.










