Yolo Vision Shenzhen
Shenzhen
Join now
Glossary

Conformal Prediction

Discover how conformal prediction provides distribution-free uncertainty for AI. Implement prediction sets with Ultralytics YOLO26 to ensure reliable model results.

Conformal prediction is a statistical framework in machine learning (ML) that provides distribution-free measures of uncertainty for model predictions. Instead of outputting a single point prediction—such as one specific class label—a conformal predictor outputs a prediction set or interval that contains the true value with a user-specified probability (e.g., 90% or 95%). This framework wraps around any artificial intelligence (AI) model to provide formal statistical guarantees without requiring changes to the model's architecture. For an exhaustive list of up-to-date tools and research, you can explore the Awesome Conformal Prediction repository.

How Conformal Prediction Works

The fundamental mechanism relies on evaluating how unusual a new prediction is compared to past examples using a nonconformity score.

  • Model Training: First, train a baseline model using a standard training dataset.
  • Calibration Phase: Pass a separate, held-out calibration dataset through the trained model. Calculate a nonconformity score for each prediction, such as the inverse probability in image classification.
  • Quantile Calculation: Determine the target confidence level (e.g., 95%) and find the corresponding quantile of these calibration scores to construct the prediction sets.
  • Inference Application: During live inference, evaluate new inputs and include all possible labels whose scores fall below the calibration quantile.

You can explore mathematical proofs of this approach in the A Gentle Introduction to Conformal Prediction tutorial or learn about time-series forecasting approaches to handle temporal uncertainties.

Differentiating Conformal Prediction from Related Terms

It is crucial to distinguish this framework from standard metrics used during model testing:

Real-World Applications

Conformal prediction is indispensable in high-stakes fields where knowing the model's blind spots is critical.

  • Medical Diagnostics: When leveraging AI in healthcare to analyze scans, a model might output a set of plausible diagnoses instead of a single, potentially incorrect class. This ensures clinicians investigate all viable possibilities, supporting recent studies on reliable genomic medicine and imaging.
  • Autonomous Driving: In AI in automotive systems, applying prediction intervals to object detection generates a spatial confidence region around a pedestrian, allowing the vehicle's braking systems to account for worst-case movements safely.

Implementing Prediction Sets

Libraries like MAPIE (Model Agnostic Prediction Interval Estimator) provide built-in tools for Python, and regression tasks often utilize conformal quantile regression. You can also implement a basic conformal prediction logic using probabilities from advanced models like Ultralytics YOLO26. The following example builds a prediction set using YOLO26 classification probabilities, mimicking the logic of including top classes until a cumulative threshold is met.

from ultralytics import YOLO

# Load an Ultralytics YOLO26 classification model
model = YOLO("yolo26n-cls.pt")

# Perform inference on an image
results = model("https://ultralytics.com/images/bus.jpg")

# Simple conformal-style prediction set logic based on cumulative probability
target_coverage = 0.95
prediction_set = []
cumulative_prob = 0.0

# Sort probabilities in descending order using the results object
probs = results[0].probs
sorted_indices = probs.top5

for idx in sorted_indices:
    class_name = results[0].names[idx]
    class_prob = probs.data[idx].item()

    prediction_set.append((class_name, round(class_prob, 3)))
    cumulative_prob += class_prob

    # Stop adding to the set once we reach the 95% coverage threshold
    if cumulative_prob >= target_coverage:
        break

print(f"95% Prediction Set: {prediction_set}")

Developing reliable systems requires robust data practices to prevent data drift from ruining calibration. Tools like the Ultralytics Platform simplify the process of gathering fresh classification datasets, retraining models, and securely managing model deployment. You can read more about curating balanced data in our guide on understanding dataset bias, or track the latest advancements presented at the annual COPA conference.

Let’s build the future of AI together!

Begin your journey with the future of machine learning