📋 KEY INSIGHTS
- Conformal prediction is a framework for constructing prediction intervals that have a guaranteed coverage probability — if you request 90% coverage, the interval will contain the true label at least 90% of the time, regardless of the true data distribution. This distribution-free guarantee holds for any pre-trained model and any exchangeable data, with no additional assumptions.
- The core mechanism of split conformal prediction is simple: reserve a calibration set, score all calibration examples by a nonconformity measure (e.g. absolute residual for regression, or 1 minus the predicted class probability for classification), find the quantile of those scores that achieves the desired coverage, and use that quantile as the prediction interval half-width.
- Unlike Bayesian credible intervals or bootstrapped confidence intervals, conformal prediction intervals are valid in finite samples — you do not need a large dataset or distributional assumptions for the coverage guarantee to hold. The guarantee comes from the exchangeability of data points under random sampling, which is a much weaker assumption.
- Conformal prediction is model-agnostic: it wraps any pre-trained classifier or regressor — XGBoost, neural network, linear model — and produces valid uncertainty intervals without retraining. This makes it a practical drop-in addition to any existing ML deployment for uncertainty quantification.
- Mondrian conformal prediction (conditional conformal prediction) provides coverage guarantees within subgroups, not just marginally over the full population. This is critical for fairness and safety: a prediction interval that achieves 90% coverage overall but only 70% coverage for a protected group is not genuinely reliable for that group.
- The RAPS (Regularised Adaptive Prediction Sets) extension for classification produces variable-size prediction sets — the set of classes for which the model cannot confidently rule out the label — that are smaller (more informative) for easy examples and larger for ambiguous ones, while still maintaining the marginal coverage guarantee.
Uncertainty quantification is the missing ingredient in most deployed machine learning systems. A model that predicts “customer will churn” but cannot say whether it is 55% or 99% confident is far less useful than one that says “I am 90% confident the customer will churn within 30 days, with my uncertainty range spanning 25–35 days.” Yet the standard tools for uncertainty — Bayesian credible intervals, bootstrapped confidence intervals, Gaussian process posterior variances — either require strong distributional assumptions, are computationally expensive, or do not have finite-sample coverage guarantees. Conformal prediction fills this gap: it is a framework for constructing prediction sets and intervals that have a mathematically guaranteed coverage probability, with no distributional assumptions, for any pre-trained model, in finite samples. This makes it uniquely practical for production deployment where calibrated uncertainty is needed but expensive Bayesian retraining is not feasible. This guide covers split conformal prediction, the nonconformity score, cross-conformal and jackknife+ variants, classification prediction sets (RAPS), conditional coverage and Mondrian conformal prediction, and practical deployment considerations.
Split Conformal Prediction — The Core Algorithm
Split conformal prediction (Papadopoulos et al., 2002; Venn et al., 2005) requires three ingredients: a pre-trained model f̂, a held-out calibration set {(x₁,y₁),…,(xₙ,yₙ)} not used in training, and a user-specified coverage level 1−α (e.g. 0.90 for 90% coverage). The algorithm has three steps:
Step 1 — Score calibration examples. For each calibration example i, compute the nonconformity score sᵢ = s(xᵢ, yᵢ) — a measure of how unusual or surprising example i is relative to the model’s prediction. For regression, the standard nonconformity score is the absolute residual: sᵢ = |yᵢ − f̂(xᵢ)|. For classification, it is 1 minus the predicted probability of the true class: sᵢ = 1 − f̂(xᵢ)[yᵢ]. The choice of nonconformity score determines the efficiency (width/size) of the prediction sets but does not affect the coverage guarantee — any nonconformity score produces a valid interval.
Step 2 — Compute the calibration quantile. Find q̂ = the ⌈(n+1)(1−α)⌉/n quantile of the calibration scores {s₁,…,sₙ}. This is slightly above the 1−α quantile to account for finite-sample correction. The intuition: if 90 out of 100 calibration examples have absolute residual below q̂, then by exchangeability, a new test example has approximately 90% probability of also having residual below q̂.
Step 3 — Construct prediction intervals. For a new test input x*, the conformal prediction interval is [f̂(x*) − q̂, f̂(x*) + q̂] for regression, or the set of classes c for which 1 − f̂(x*)[c] ≤ q̂ for classification. The coverage guarantee: P(y* ∈ Ĉ(x*)) ≥ 1 − α, holding exactly in finite samples under exchangeability. This guarantee applies to any pre-trained model f̂ — it does not matter whether f̂ is a gradient boosted tree, a neural network, a linear model, or a Gaussian process. The split conformal wrapper adds valid uncertainty to any existing model without retraining.
| Variant | Calibration Data Used | Coverage Guarantee | Efficiency | Cost |
|---|---|---|---|---|
| Split conformal | Separate calibration set | Marginal, finite-sample | Good (wastes calibration data) | O(n) inference |
| Cross-conformal | K-fold splits | Approximate marginal | Better (uses all data) | K × training cost |
| Jackknife+ | Leave-one-out residuals | Marginal, finite-sample | Best (no data waste) | n × training cost (expensive) |
| CV+ | K-fold leave-one-out approx | Marginal, finite-sample | Near-optimal | K × training cost |
| Mondrian conformal | Calibration set per stratum | Conditional on stratum | Stratum-dependent | O(n) per stratum |
Classification Prediction Sets and Adaptive Coverage
For classification tasks, conformal prediction produces prediction sets — sets of class labels that contain the true label with probability 1−α. A basic implementation includes all classes c for which 1 − f̂(x*)[c] ≤ q̂. The resulting prediction set size varies by example: for easy, unambiguous examples, the set contains only one class (the clear winner); for ambiguous examples near decision boundaries, the set may contain two or three classes. This variable set size is a feature — it communicates the model’s genuine uncertainty per example — rather than a limitation.
RAPS (Regularised Adaptive Prediction Sets) (Angelopoulos et al., 2020) improves on basic conformal classification by using a nonconformity score that penalises large prediction sets, encouraging the algorithm to produce smaller sets while still maintaining coverage. The RAPS score adds a regularisation term proportional to the size of the set: sᵢ(c) = Σ_{j: rank(j) ≤ rank(c)} f̂(x)[j] + λ · (rank(c) − o)₊, where rank(c) is the rank of class c by predicted probability, λ controls regularisation strength, and o is the target set size. RAPS produces tighter prediction sets than vanilla conformal, particularly on well-separated classes. It is the standard approach for computer vision classification tasks where hundreds or thousands of classes make large prediction sets uninformative.
The connection to model calibration is important: conformal prediction and calibration are complementary, not competing. Calibration ensures that a predicted probability of 70% corresponds to events occurring 70% of the time. Conformal prediction ensures that a prediction interval covers the true value with the stated probability. A well-calibrated model produces more efficient (narrower) conformal intervals, because its probability estimates are more accurate. Our Bayesian statistics guide covers calibration and the Platt scaling / isotonic regression methods for recalibrating a model’s predicted probabilities before applying conformal prediction.
Conditional Coverage and Fairness
The marginal coverage guarantee — P(y* ∈ Ĉ(x*)) ≥ 1−α over the full test distribution — does not imply conditional coverage — P(y* ∈ Ĉ(x*) | x* ∈ G) ≥ 1−α for a subgroup G. A prediction interval that is 90% correct overall but only 75% correct for a specific demographic group provides misleading reliability for that group. In regulated applications — medical diagnosis, credit decisioning, hiring — conditional coverage by protected characteristic is a fairness requirement, not an optional feature. Our data science ethics guide covers the broader landscape of fairness metrics and regulatory requirements for model outputs.
Mondrian conformal prediction partitions the calibration set into strata (e.g. by demographic group, prediction confidence level, or input region), computes a separate calibration quantile for each stratum, and applies the stratum-specific quantile to each test example. This achieves conditional coverage within strata — P(y* ∈ Ĉ(x*) | strat(x*) = k) ≥ 1−α for each stratum k — at the cost of requiring sufficient calibration data within each stratum. When strata are too small for reliable quantile estimation, the coverage guarantee degrades. This same tradeoff between marginal and conditional validity applies across many fairness-aware ML methods covered in our model interpretability and causal inference guides.
Conformal prediction is deployable in production ML systems with minimal engineering overhead: the calibration step runs once after model training, and inference requires only a lookup of the pre-computed quantile q̂. The MAPIE Python library provides a sklearn-compatible interface for split conformal, cross-conformal, and Mondrian conformal prediction across regression and classification tasks. Integration into the model deployment pipeline alongside standard REST API serving is straightforward — the conformal interval is an additional field in the model’s JSON response, requiring no changes to the model architecture or training procedure.
✦ SUMMARIZE THIS ARTICLE WITH AI
Model calibration — the prerequisite for efficient conformal intervals — is in our Model Evaluation guide. Bayesian uncertainty quantification — the complementary approach to conformal prediction — is in our Bayesian Statistics guide and our Gaussian Processes guide. Fairness and conditional coverage requirements are in our Data Science Ethics guide. Monte Carlo bootstrap confidence intervals — another distribution-free uncertainty approach — are in our Monte Carlo Methods guide. Deployment of conformal prediction in production API services is in our ML Model Deployment guide.



