Home AI/ML Conformal Prediction: Distribution-Free Uncertainty Quantification

Conformal Prediction: Distribution-Free Uncertainty Quantification

kongastral

Published September 8, 2026 · 17 min read

A deployed image classifier receives a photograph, runs it through the network, and returns the label “malignant” with a softmax score of 0.83. A reviewer asks a direct question: what, precisely, does 0.83 guarantee about whether this particular prediction is correct? The honest answer is nothing. The softmax value is an internal quantity produced by the final layer of the model; it is not a validated probability, and modern deep networks are frequently overconfident, assigning high scores to inputs they classify incorrectly. A score of 0.83 does not mean that 83 percent of inputs receiving that score are labelled correctly, and it offers no formal statement about the reliability of any single decision.

Conformal prediction addresses this gap. Rather than reporting a point prediction attached to an uncalibrated confidence number, it produces a prediction set — a set of labels for classification, or an interval for regression — that is mathematically guaranteed to contain the true outcome with a user-specified frequency, for example 90 percent of the time. The guarantee is distribution-free (it makes no assumption that the data follows a Gaussian or any other parametric family), finite-sample (it holds for the calibration set actually collected, not only in the limit of infinite data), and model-agnostic (it wraps any predictor, including a neural network, a gradient-boosted tree, or a Gaussian process). This guide explains the mechanism, works through the arithmetic that produces the guarantee, and states carefully what the guarantee does and does not promise.

Summary

What this post covers: How conformal prediction converts any trained model into one that outputs prediction sets or intervals with a proven, distribution-free coverage guarantee, and the precise conditions under which that guarantee holds.

Key insights:

  • Split conformal prediction guarantees marginal coverage of at least 1 − α, with a matching upper bound of 1 − α + 1/(n+1), where n is the calibration-set size.
  • The guarantee comes from a single calibration step: compute nonconformity scores, then take their ⌈(n+1)(1−α)⌉-th smallest value as a threshold — a deterministic quantile computation, not a fitted parameter.
  • The coverage is marginal (averaged over inputs), not conditional (guaranteed for every input); exact conditional coverage is impossible to achieve distribution-free.
  • The guarantee rests on exchangeability of calibration and test data; covariate or label shift breaks it, and weighted conformal prediction is the standard remedy.

Main topics: Split conformal prediction, the quantile threshold, marginal versus conditional coverage, APS and RAPS for classification, conformalized quantile regression, distribution shift.

Split (inductive) conformal prediction

Conformal prediction originated in machine learning in the late 1990s, and the foundational treatment is the monograph by Vovk, Gammerman, and Shafer, Algorithmic Learning in a Random World (Springer, 2005). The original formulation is transductive, or full, conformal prediction: for each candidate label it refits or recomputes scores over the entire dataset. This is statistically clean but computationally expensive, because the work scales with the number of candidate labels and dataset size. The variant used in almost all modern practice is split, or inductive, conformal prediction, which requires only a single train/calibration split and one fit of the model.

The procedure has four steps, following the exposition of Angelopoulos and Bates (arXiv:2107.07511). First, partition the available labelled data into a proper training set and a calibration set of size n; the calibration points must not be used to fit the model. Second, fit the model on the training set only. Third, define a nonconformity score s(x, y) that measures how poorly the label y fits the input x, where a higher score means a worse fit, and compute this score for each of the n calibration points. Fourth, for a new test input, form the prediction set as every label whose nonconformity score falls at or below a threshold q̂ derived from the calibration scores.

Split (inductive) conformal prediction Labelled data Training set used to fit the model only Calibration set (size n) held out from fitting Fitted model f Nonconformity scores s(x₁,y₁) … s(xₙ,yₙ) Threshold q̂ ⌈(n+1)(1−α)⌉-th smallest score Test input x_test Prediction set C(x_test) = { y : s(x_test, y) ≤ q̂ }

The single most important property of this construction is that the threshold is not a tuned hyperparameter. It is a specific order statistic of the calibration scores, computed once, and the coverage guarantee follows from a symmetry argument rather than from any assumption about the model’s quality. A poorly trained model yields large, uninformative prediction sets, but the coverage guarantee still holds; the model’s accuracy affects the size of the sets, not their validity.

The quantile threshold: a worked example

The threshold q̂ is defined as the ⌈(n+1)(1−α)⌉ / n empirical quantile of the calibration scores s₁, …, sₙ, where α is the chosen miscoverage rate — for 90 percent coverage, α = 0.1. Equivalently, sort the n scores in ascending order and take the ⌈(n+1)(1−α)⌉-th smallest value (Angelopoulos and Bates, arXiv:2107.07511, §1.1). The ceiling function ⌈·⌉ rounds up to the next integer. The small inflation from n to n+1 is exactly what buys the finite-sample guarantee: using the plain 1−α quantile would systematically undercover, because it ignores the test point’s own contribution to the ordering.

Consider a concrete case with a calibration set of n = 1000 points and a target coverage of 90 percent, so α = 0.1. The computation is deterministic:

(n + 1)(1 - alpha) = 1001 x 0.9 = 900.9
ceil(900.9)        = 901
threshold q_hat    = the 901st smallest calibration score
                     (empirical quantile level 901 / 1000 = 0.901)

The prediction set for a test input then contains every candidate label whose nonconformity score is at or below the 901st smallest calibration score. No optimisation, no gradient step, and no distributional assumption enter this calculation; it is hand arithmetic on the sorted scores. This threshold delivers the two-sided coverage bound

1 − α ≤ P(Y_test ∈ C(X_test)) ≤ 1 − α + 1/(n+1)

For n = 1000 and α = 0.1, the true coverage is guaranteed to lie between 0.900 and 0.900 + 1/1001 ≈ 0.901. The upper bound matters in practice: it shows that split conformal does not overcover wastefully, so the guarantee is tight rather than merely conservative.

Calibration scores and the 1−α quantile threshold nonconformity score s(x, y) → worse fit count q̂ = 901st smallest score ≈ 90% of calibration mass (labels admitted to the set) excluded

Caution: If ⌈(n+1)(1−α)⌉ exceeds n, the required quantile is +∞ and the prediction set becomes the entire label space. Coverage is then trivially satisfied but the output carries no information. This occurs when the calibration set is too small for the requested α; for example, 99 percent coverage (α = 0.01) requires at least 99 calibration points before the threshold is finite. A sufficiently large calibration set is a prerequisite for useful sets, not merely valid ones.

Marginal versus conditional coverage

The precise meaning of the guarantee is easy to overstate, and the distinction between two forms of coverage is where most misunderstandings arise. The split conformal guarantee is marginal: the probability 1 − α is averaged over the randomness in both the calibration set and the test point (Angelopoulos and Bates, arXiv:2107.07511, §3.1). It states that if the procedure is repeated across many draws of calibration and test data, the true label falls inside the set at least 90 percent of the time on average across all inputs.

Conditional coverage is the stronger property that P(Y_test ∈ C(X_test) | X_test) ≥ 1 − α holds for every specific value of the input X_test — that the guarantee applies separately to each subpopulation, such as each patient demographic or each image category. In the fully general distribution-free, finite-sample setting, exact conditional coverage is impossible to achieve (Angelopoulos and Bates, arXiv:2107.07511, §3.1). Split conformal delivers only the marginal guarantee. This is a genuine limitation: a procedure can achieve exactly 90 percent coverage overall while overcovering easy inputs and undercovering hard ones, so that a particular hard region receives systematically less protection than the headline number suggests.

Marginal coverage can hide uneven protection Marginal (guaranteed) Conditional (not guaranteed) 90% target 90% target Easy 96% Medium 94% Hard 80% average = 90% ✓ Easy 93% Medium 92% Hard 91% every group ≥ 90%

The practical response is to use a score function that improves approximate conditional coverage, so that set sizes adapt to input difficulty even though no exact per-input guarantee is available. This design goal motivates the adaptive score functions described in the next two sections. The relationship to probability calibration is worth stating precisely, because the two ideas are often confused: calibration adjusts scalar probabilities so that predicted confidences match observed frequencies, but it provides no finite-sample coverage guarantee, whereas conformal prediction provides the guarantee but returns sets rather than adjusted scalars. The two are complementary — a well-calibrated softmax is often the ideal base score for conformal classification. Readers building intuition for the calibration side may consult the companion discussion of expected calibration error and reliability diagrams.

Prediction sets for classification: APS and RAPS

In classification, the choice of nonconformity score determines the quality of the resulting sets. The simplest choice is the softmax score s(x, y) = 1 − f(x)_y, where f(x)_y is the softmax output the model assigns to the true class y. A label is admitted to the set when its softmax value is high enough that 1 minus that value falls below the threshold. This score is easy to compute, but it tends to undercover hard examples and overcover easy ones, producing sets that are too small precisely where the model is most uncertain (Angelopoulos and Bates, arXiv:2107.07511, §4).

Adaptive Prediction Sets (APS) improve on this by accumulating the sorted softmax probabilities from most to least likely until the true class is reached, so the score reflects the total probability mass the model places ahead of the correct label. This yields better adaptivity across inputs. Regularized APS (RAPS) adds a penalty that discourages the long tail of unlikely classes from entering the set, producing smaller and more stable sets. On ImageNet and ImageNet-V2 with classifiers such as ResNet-152, RAPS achieves the target coverage with sets that are often smaller than those from earlier methods (Angelopoulos, Bates, Malik, and Jordan, ICLR 2021, arXiv:2009.14193).

Set size signals per-example uncertainty Easy input Hard input C(x) = { tabby cat } tabby cat — 0.94 Egyptian cat — 0.03 lynx — 0.01 size 1: confident C(x) = { 4 labels } timber wolf — 0.34 grey fox — 0.27 coyote — 0.21 husky — 0.13 size 4: ambiguous

The interpretive payoff is that the size of a conformal prediction set is a per-example, human-readable signal of model uncertainty. A singleton set indicates confidence; a large set flags an input the model finds ambiguous and that may warrant human review. This is a more actionable output than a single softmax number, because it is grounded in the coverage guarantee rather than in an uncalibrated internal score. Where the base predictor itself is trained without labels, for instance through self-supervised pretraining, conformal prediction still applies unchanged: it wraps whatever model produces the scores.

Conformalized quantile regression

For regression, the analogous output is a prediction interval rather than a set of labels. A naive approach applies split conformal to the absolute residuals of a point predictor, but this yields intervals of constant width across all inputs, which is a poor fit when uncertainty varies with the input — the condition known as heteroscedasticity. Conformalized Quantile Regression (CQR) resolves this by wrapping a quantile-regression model, which directly predicts a lower and an upper conditional quantile, such as the 5th and 95th percentiles of the response (Romano, Patterson, and Candès, NeurIPS 2019, arXiv:1905.03222).

CQR conformalizes the quantile model’s interval using a nonconformity score that measures how far the true value falls outside the predicted lower–upper band, then adjusts the band by the calibrated threshold. The result inherits both properties that matter: the finite-sample, distribution-free validity of conformal prediction, and the adaptivity of quantile regression, so that interval width grows in regions of high local uncertainty and shrinks where the response is predictable. This is the regression counterpart of adaptive set size in classification.

CQR intervals widen where uncertainty grows input x (noise increases →) response y narrow band low local uncertainty wide band high local uncertainty

CQR sits alongside model-based approaches to regression uncertainty, and the contrast is instructive. A Gaussian process, discussed in the guide to Bayesian regression with Gaussian processes, produces uncertainty from a probabilistic model whose calibration depends on the prior and likelihood being approximately correct. Conformal prediction makes no such assumption: it can wrap a Gaussian process, a neural network, or a gradient-boosted tree and repair the coverage of whatever intervals that model produces, at the cost of the marginal-only guarantee discussed above.

When exchangeability breaks: distribution shift

The coverage guarantee is not free of assumptions. It requires that the calibration points and the test point be exchangeable — informally, that their joint distribution is unchanged under reordering, so that the test point is statistically interchangeable with the calibration points. Independent and identically distributed (i.i.d.) data is the most common special case of exchangeability, and the theorem in Angelopoulos and Bates (arXiv:2107.07511) is stated under the i.i.d. assumption, while the broader conformal literature works under exchangeability more generally (Vovk, Gammerman, and Shafer, 2005).

Exchangeability is exactly what fails under distribution shift. Under covariate shift, the distribution of inputs changes between calibration and deployment while the input-to-label relationship is stable; under label shift, the class balance changes. In either case the calibration and test points are no longer exchangeable, and the marginal coverage guarantee no longer holds. A conformal system that reported valid 90 percent coverage at deployment can silently drop below its target as the input distribution drifts, which is why coverage should be monitored as an operational metric rather than assumed to persist. The mechanisms and detection of such drift are treated separately in the discussion of data drift and concept drift in production machine learning.

Key Takeaway: Weighted conformal prediction restores validity under covariate shift when the likelihood ratio between test and training covariate densities is known or can be estimated, for example from unlabelled test covariates. It reweights the calibration scores so that exchangeability is recovered in a weighted sense (Tibshirani, Foygel Barber, Candès, and Ramdas, NeurIPS 2019, arXiv:1904.06019).

The nonconformity score at the centre of conformal prediction also has a conceptual parallel in anomaly detection, where a model likewise assigns a “how unusual is this point” score; the boundary-based scores used in methods such as Deep SVDD for one-class anomaly detection play an analogous role, though the guarantees and objectives differ.

Tooling and practical notes

Several open-source libraries implement conformal prediction, and the durable point is that all of them follow the same mechanism — fit any model, compute calibration scores, take a quantile threshold — so the choice among them is a matter of ecosystem fit rather than of statistical correctness.

Library Ecosystem Notes
MAPIE scikit-learn A fit/predict wrapper for conformal intervals, classification sets (including APS/RAPS-style methods), and time series; scikit-learn compatible.
TorchCP PyTorch PyTorch-native, integrating conformal prediction with deep classifiers, regressors, and online prediction, with GPU-accelerated batch processing.
crepes NumPy / general A lightweight library for conformal classifiers, regressors, and predictive systems; CPU-oriented, without GPU or batch acceleration.

 

Tip: Hold out a dedicated calibration set that is never touched during model fitting or hyperparameter selection. Reusing training or validation data as calibration data breaks the exchangeability argument and invalidates the guarantee. When labelled data is scarce, cross-conformal and jackknife+ variants reuse data more efficiently while retaining a coverage guarantee.

Related Reading

Frequently Asked Questions

Does conformal prediction require the model to be accurate?

No. The coverage guarantee holds regardless of model quality, because it derives from a symmetry argument over the calibration scores rather than from any assumption about accuracy. Model quality affects the size of the prediction sets or the width of the intervals, not their validity: a weak model produces valid but large, uninformative sets, while a strong model produces valid and small ones.

How is conformal prediction different from probability calibration?

Probability calibration adjusts a model’s scalar confidence scores so that, for example, predictions made with 0.8 confidence are correct about 80 percent of the time; it provides no finite-sample guarantee. Conformal prediction instead outputs a set or interval with a proven marginal coverage guarantee. The two are complementary — a well-calibrated score is often the best base score for conformal classification — but only conformal prediction supplies the formal coverage statement.

What does the 90 percent coverage guarantee actually promise?

It promises marginal coverage: averaged over the randomness in the calibration and test data, the true outcome falls inside the prediction set at least 90 percent of the time, with a matching upper bound of 1 − α + 1/(n+1). It does not promise conditional coverage — 90 percent protection for every individual input or subpopulation — which is impossible to guarantee distribution-free. Coverage can be uneven across easy and hard inputs even when the overall rate is met.

What breaks the coverage guarantee in production?

The guarantee rests on exchangeability between the calibration and test data. Distribution shift — covariate shift or label shift — breaks exchangeability, so a deployed system’s true coverage can fall below its target as the data drifts. Coverage should therefore be monitored operationally. Weighted conformal prediction can restore validity under covariate shift when the density ratio between test and training inputs can be estimated.

Conclusion

Conformal prediction offers a rare combination in applied machine learning: a guarantee that is simultaneously distribution-free, finite-sample, and model-agnostic, obtained through a single calibration step that reduces to a deterministic quantile computation. The 0.83 softmax score that opened this guide can be replaced by a prediction set whose coverage is provable and whose size communicates uncertainty in a form a reviewer can act on. The essential discipline is to state the guarantee accurately — it is marginal, not conditional — and to remember that it depends on exchangeability, which distribution shift can quietly break. Used with that awareness, and monitored in production, conformal prediction turns an uncalibrated confidence number into a defensible statement about reliability.

References

  1. Angelopoulos, A. N., and Bates, S. A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification. arXiv:2107.07511. arxiv.org/abs/2107.07511
  2. Vovk, V., Gammerman, A., and Shafer, G. Algorithmic Learning in a Random World. Springer, 2005. Springer
  3. Romano, Y., Patterson, E., and Candès, E. J. Conformalized Quantile Regression. NeurIPS 2019. arXiv:1905.03222. arxiv.org/abs/1905.03222
  4. Angelopoulos, A. N., Bates, S., Malik, J., and Jordan, M. I. Uncertainty Sets for Image Classifiers using Conformal Prediction. ICLR 2021. arXiv:2009.14193. arxiv.org/abs/2009.14193
  5. Tibshirani, R. J., Foygel Barber, R., Candès, E. J., and Ramdas, A. Conformal Prediction Under Covariate Shift. NeurIPS 2019. arXiv:1904.06019. arxiv.org/abs/1904.06019

You Might Also Like

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *