Distribution-Free Uncertainty
Neural networks are pathologically overconfident. A model trained to minimize cross-entropy will cheerfully predict a 99% probability for…
Distribution-Free Uncertainty
Neural networks are pathologically overconfident. A model trained to minimize cross-entropy will cheerfully predict a 99% probability for the wrong class when shown out-of-distribution data. Bayesian methods offer a principled alternative, but they come with a heavy price: priors that influence results, intractable posteriors that require approximation, and inference costs that scale poorly.
There is a third way. Conformal prediction delivers finite-sample coverage guarantees without assuming anything about the data distribution or model architecture. No Bayes. No variational approximations. Just a clever use of the empirical distribution of errors.
The Core Problem
Suppose we have a model f trained to map inputs X to predictions. We want not a point prediction, but a prediction set C(X) such that:
P(Y ∈ C(X)) ≥ 1 − α
for some miscoverage level α ∈ (0, 1). In words: we want a set that traps the true label with probability at least 1 − α. This is marginal coverage over a random draw of (X, Y) from the same distribution.
Standard classification outputs class probabilities, but these are neither calibrated nor distributionally robust. Conformal prediction wraps any pretrained model and converts it into a set-valued predictor with a provable coverage guarantee.
Split Conformal Prediction: The Algorithm
The split conformal approach is disarmingly simple. We split our data into a proper training set and a calibration set. We fit f on the training set, then compute a nonconformity score s(Xi, Yi) on every calibration point. This score measures how “strange” a pair (X, Y) is according to our model. Common choices include:
- Classification: s(X, Y) = 1 − π̂Y(X), where π̂Y is the predicted probability of the true class.
- Regression: s(X, Y) = |Y − f̂(X)|, the absolute residual.
Let s₁, …, sₙ be the scores on the n calibration points. We compute the empirical quantile:
q̂ = ⌈(n + 1)(1 − α)⌉ / n quantile of {s₁, …, sₙ}
At test time, for a new point Xn+1, we include in our prediction set every label y whose score falls below the threshold:
C(Xn+1) = { y : s(Xn+1, y) ≤ q̂ }That’s it. The algorithm is model-agnostic, works with any score function, and requires only exchangeability (a weaker condition than i.i.d.).
The Coverage Guarantee
Theorem (Marginal Coverage). If (X₁, Y₁), …, (Xₙ, Yₙ), (Xₙ₊₁, Yₙ₊₁) are exchangeable, then the split conformal prediction set satisfies:
P(Yn+1 ∈ C(Xn+1)) ≥ 1 − α
The proof is remarkably short. Let sn+1 be the test score. By exchangeability, the rank of sn+1 among the pooled set {s₁, …, sₙ₊₁} is uniformly distributed over {1, …, n + 1}. The probability that sn+1 exceeds ⌈(n+1)(1−α)⌉ of the calibration scores is at most α. The result follows immediately.
Notice what we did not assume. We did not assume Gaussian errors. We did not assume our model was well-specified. We did not assume the data was i.i.d. — only that the test point is exchangeable with calibration data. This is why conformal prediction is exploding in medical imaging, financial risk, and safety-critical robotics: it provides guarantees when nothing else can.
Beyond Sets: Conformalized Quantile Regression
A naive application to regression gives constant-width intervals, which is wasteful in low-uncertainty regions. Conformalized Quantile Regression (CQR) improves this by training two quantile regressors, q̂α/2 and q̂₁₋α/₂, to estimate the lower and upper bounds. The nonconformity scores become:
si = max{ q̂α/2(Xi) − Yi , Yi − q̂1−α/2(Xi) }
Conformalization then adjusts these quantiles to guarantee coverage while preserving the local adaptivity of the underlying regression. You get tight intervals where the model is confident and wide intervals where it is uncertain — exactly the behavior we intuitively want.
“In a world of black-box models and black-swan failures, conformal prediction is the only tool that lets you say ‘I am 95% certain’ and actually mean it mathematically.”
메타데이터
- post_id
- cb6d60cfacce
- slug
- distribution-free-uncertainty-cb6d60cfacce
- url
- https://medium.com/@samraamin222/distribution-free-uncertainty-cb6d60cfacce
- canonical_url
- https://medium.com/@samraamin222/distribution-free-uncertainty-cb6d60cfacce
- author_url
- https://medium.com/@samraamin222
- status
- ok
- fetched_at
- 2026-07-29 23:11:35