Conformity Scores and Adaptive Prediction Sets
Summary
The score function is the only design choice in conformal prediction. Validity holds for every score — even pure noise — but “the usefulness of the prediction sets is primarily determined by the score function” (A&B p. 6). A good score ranks inputs by the magnitude of model error, so that sets are small for easy inputs and large for hard ones (adaptivity). This note catalogues the scores in Angelopoulos & Bates Sec. 2 — softmax threshold, adaptive prediction sets (APS), scaled residuals , and the posterior predictive density — together with Romano et al.’s critique of locally adaptive residual scores that motivates Conformalized Quantile Regression.
Overview
After fixing the recipe in Split Conformal Prediction and the Coverage Guarantee, all remaining freedom lies in . A&B’s thought experiment: if the scores are random noise, the conformal set is a random subset of the label space, large enough to cover with probability — valid and useless. If instead the scores correctly rank examples from smallest to largest model error, sets shrink on easy inputs and grow on hard ones. The score “incorporates almost all the information we know about our problem and data, including the underlying model itself”; the main difference between conformal classification and conformal regression is simply the choice of score.
Convention: larger score = worse agreement between and (a nonconformity score). The prediction set is always the sub-level set , with the calibration quantile.
Main Content
Classification
Softmax-threshold score (A&B Sec. 1) ^def-softmax-score
, one minus the softmax output of the true class. The set is . This procedure yields the smallest average set size among conformal classifiers (Sadinle et al.), but “tends to undercover hard subgroups and overcover easy ones” (A&B p. 6): a single global probability threshold ignores how the remaining mass is spread.
Adaptive prediction sets, APS (Romano, Sesia & Candès; Angelopoulos et al.; A&B Sec. 2.1) ^def-aps
Let be the permutation of sorting from most to least likely. Define
the cumulative softmax mass accumulated until the true label is reached. The prediction set (modified slightly to avoid empty sets) is
APS is motivated by an oracle: if were the true conditional distribution of , greedily including top classes until their mass exceeds would give exact conditional coverage. Since is only heuristic, conformal calibration replaces by . Unlike the softmax-threshold score, APS uses the softmax outputs of all classes, not just the true one. The trade-off is larger average sets in exchange for better approximate conditional coverage; A&B point to Angelopoulos, Bates, Malik & Jordan (2021) for “significant practical improvements” on set size.
Regression with a scalar uncertainty estimate
Scaled-residual score (A&B Sec. 2.3) ^def-scaled-residual
Given a point predictor and any uncertainty scalar that is large when the model is unsure,
is a multiplicative correction factor for the heuristic uncertainty: .
Choices of listed by A&B: a Gaussian-likelihood network’s (e.g. trained with GaussianNLLLoss); a second model fit to ; variance of across an ensemble; variance under MC dropout; variance under small input perturbations; variance over noise samples of a generative model; sensitivity to adversarial perturbation. All are treated identically. With this reduces to the absolute-residual score and a constant-width band.
Two caveats from the sources:
- Symmetry and -scaling. The sets are symmetric about , and “uncertainty scalars do not necessarily scale properly with ”: there is no reason a is proportional to the relevant quantile of at every level. A&B “tend to prefer quantile regression when possible”.
- Training-residual bias (Romano et al. Sec. 5). In locally adaptive conformal prediction is a MAD estimate fit to residuals on the proper training set, often with an offset, . Those residuals “are biased by an optimization procedure designed to minimize them”, so an over-parameterised (training error near zero) gives a nearly useless , forcing to be large and destroying adaptivity. On homoscedastic data the extra estimation noise in actually inflates intervals relative to plain split conformal.
Both caveats point to Conformalized Quantile Regression, whose score is asymmetric-capable and trained directly for the target quantiles.
Conformalizing Bayes
Posterior-predictive density score (A&B Sec. 2.4) ^def-conformal-bayes
For a Bayesian model with posterior predictive density , set
The set is a super-level set of the posterior predictive density — the shape of a highest-density region, with the cut-off chosen by conformal calibration rather than by integrating the density to .
A Bayesian who believed the model would use with . That relies on “a correctly specified model and asymptotically large “. The conformal version is valid without those assumptions, and under the technical conditions of Hoff (A&B ref. [11]) it has the smallest average size (Bayes risk) among conformal procedures with coverage — an argument A&B liken to the Neyman–Pearson lemma. Multi-modal predictive densities naturally produce unions of intervals.
Score-selection heuristics
Goal Score Set shape Smallest average classification set global probability threshold Adaptive classification sets APS cumulative mass top- classes Regression, quantile learner available CQR score Regression, only or an ensemble Bayesian model with a predictive density HPD-shaped, possibly disconnected
Evaluating adaptivity (A&B Sec. 3.1)
The procedure with the smallest average set is not necessarily best. A&B recommend: (i) histogram set sizes — a wide spread suggests the procedure distinguishes easy from hard inputs; (ii) verify the large sets occur on the hard examples via feature-stratified (FSC) and size-stratified (SSC) coverage, defined in Marginal vs Conditional Coverage.
Examples
APS in NumPy, following A&B Figure 3:
import numpy as np
def aps_calibrate(cal_smx, cal_labels, alpha=0.1):
n = len(cal_labels)
pi = cal_smx.argsort(1)[:, ::-1] # classes sorted by prob
srt = np.take_along_axis(cal_smx, pi, axis=1).cumsum(axis=1) # cumulative mass
scores = np.take_along_axis(srt, pi.argsort(1), axis=1)[np.arange(n), cal_labels]
return np.quantile(scores, np.ceil((n + 1) * (1 - alpha)) / n, method="higher")
def aps_predict(val_smx, qhat):
pi = val_smx.argsort(1)[:, ::-1]
srt = np.take_along_axis(val_smx, pi, axis=1).cumsum(axis=1)
return np.take_along_axis(srt <= qhat, pi.argsort(1), axis=1) # boolean set matrixWorked contrast. Softmax vectors and with . APS keeps classes while the cumulative mass before adding the next class is below : for the first input the cumulative sums are , giving the set ; for the second, , giving all four classes. A softmax-threshold rule whose own calibration gave the cut-off would return and respectively — confidently excluding three classes that jointly carry 45% of the mass. This is the under-coverage on hard inputs that APS repairs.
Conformalizing a Bayesian regression. For a PyMC/Stan regression, evaluate the posterior predictive density at each held-out (average the likelihood over posterior draws), take as its negative, compute , and report . If implies a density cut-off far lower than the nominal HPD cut-off, the posterior predictive is over-confident — a quantitative complement to Posterior Predictive Checking.
Connections
- Split Conformal Prediction and the Coverage Guarantee — why any score is valid.
- Conformalized Quantile Regression — the preferred regression score and the empirical comparison against scaled residuals.
- Marginal vs Conditional Coverage — adaptivity is the practical proxy for conditional coverage.
- Conformal Prediction - Overview — where scores sit in the four-step recipe.
- Posterior Predictive Checking — the posterior predictive is the raw material of the conformalized-Bayes score.
- Quantile Regression — the classical estimator behind the CQR score.
See Also
- Stacking and Predictive Model Averaging — ensembles supply both a better and a disagreement-based .
- Hierarchical Models — partial pooling gives group-varying predictive scales that make natural uncertainty scalars.
- Simulation-Based Calibration - Overview — checks the Bayesian computation; conformalized Bayes guards against model misspecification instead.