1  Understanding conformal prediction

1.1 Why uncertainty matters

A model is trained to predict how long a patient will need to recover after a procedure. For one patient, it returns 18 days.

The prediction does not show how much recovery times vary among similar patients. A prediction of 18 days could come with a narrow range of plausible outcomes or a range from 5 to 40 days. Those situations require different decisions even though the point prediction is the same.

Three columns labeled Patient A, Patient B, and Patient C. Each has a diamond marker at 18 days, the shared predicted value, and a cloud of jittered points showing plausible outcomes. Patient A's cloud is narrow, Patient B's is wider, and Patient C's is widest, spanning roughly from 0 to 40 days.
Figure 1.1: Three patients with the same predicted recovery time, but very different plausible spreads around it.

In Figure 1.1, all three patients have a prediction of 18 days, but the plausible spread differs. A point prediction does not show this difference.

The same problem occurs in classification. Consider three class probabilities:

Bar chart with three bars: A at 0.51, B at 0.47, and C at 0.02. A bracket above A and B is labeled retained. A title reads: predicted class A, prediction set A B.
Figure 1.2: A classifier’s probabilities for three classes. A and B are close together, and C is very unlikely.

A classifier that returns only the most likely class reports A. In Figure 1.2, A has probability 0.51 and B has probability 0.47. A prediction of 0.51 is much less decisive than a prediction of 0.98, but both cases receive the same label.

Conformal prediction adds a prediction interval in regression or a prediction set in classification. Under the assumptions described below, the interval or set contains the outcome at a chosen long-run rate. The classifier above might return \(\{A, B\}\) rather than only A.

1.2 Intervals, probabilities, and prediction sets

Several forms of uncertainty have different meanings.

A confidence interval describes uncertainty about a fixed but unknown quantity, such as a regression coefficient or population mean.

A prediction interval gives a range for a future or held-out outcome. It concerns an observation of \(Y\), not a model parameter.

A class probability is the probability that a classifier assigns to one class.

A prediction set contains the classes retained by a conformal classifier. Depending on the method and observation, it may contain one class, several classes, no classes, or every class.

Two rows. Regression row: a single point prediction of 18 on the left, and a prediction interval from 11 to 25 with the point prediction marked inside it on the right. Classification row: a single predicted class A on the left, and a prediction set containing A and B on the right.
Figure 1.3: Point predictions next to their interval or set counterparts, for both regression and classification.

This chapter concerns prediction intervals and prediction sets, not confidence intervals for model parameters.

1.3 Models without prediction intervals

Some models provide prediction intervals under specific assumptions. Classical linear regression is one example. Many predictive models return only a point or class probabilities by default. Variation among random-forest trees is not itself a calibrated prediction interval, and standard gradient-boosting models do not attach an interval to each prediction.

Conformal prediction can be applied to many fitted models, including linear models, random forests, gradient boosting, and neural networks. It uses held-out data to turn their predictions into intervals or sets. The model does not need to provide its own uncertainty estimate.

1.4 Training, calibration and test data

Split conformal prediction assigns separate roles to training, calibration, and test data.

Three colored boxes side by side: training data, which feeds into fitting the model, calibration data, which feeds into measuring how prediction errors behave on unseen observations, and test data, which feeds into evaluating the completed procedure.
Figure 1.4: Three separate data sets, each doing a different job.

The training data fit the predictive model. The calibration data measure its errors on observations not used for fitting. The test data evaluate the completed model and conformal procedure. Figure 1.4 shows these roles.

Training errors cannot replace calibration errors because the model has already used those observations.

Overlaid histograms of absolute prediction error for a flexible model. The training error histogram is a tall spike at zero. The calibration error histogram, computed on unseen data from the same distribution, is spread out with a mean well above zero.
Figure 1.5: Errors on the data a model was trained on are systematically smaller than its errors on genuinely new data.

In Figure 1.5, a flexible model nearly memorizes its training data. Its training errors are close to zero, while its errors on unseen calibration observations are much larger. Training residuals are therefore too optimistic for split conformal calibration.

1.5 Probability calibration and conformal calibration

Probability calibration and conformal calibration are different procedures.

Probability calibration compares predicted probabilities with observed frequencies. Among cases assigned probability 0.70, the event should occur about 70% of the time.

Conformal calibration uses scores from held-out observations to determine the size of a prediction interval or set. It does not make class probabilities calibrated and usually does not change the fitted model.

Two panels. Left: a reliability diagram, predicted probability on the horizontal axis, observed event frequency on the vertical axis, with a diagonal reference line for perfect calibration. Right: a flow diagram, held-out observations leading to a distribution of nonconformity scores, leading to a prediction interval or set.
Figure 1.6: Probability calibration and conformal calibration ask different questions.

1.6 Nonconformity scores

A nonconformity score measures disagreement between a prediction and an observed outcome. Small scores indicate better agreement and large scores indicate worse agreement.

The simplest regression score is the absolute residual, the absolute difference between the outcome and its prediction. Quantile regression and classification use other scores, but retain the same direction: smaller means more agreement.

Histogram of absolute residuals from 200 calibration observations, right-skewed, with a red dashed cutoff line near the upper tail. Three triangular markers below the axis indicate an observation that agrees well with the model, a typical observation, and an observation that agrees poorly with the model.
Figure 1.7: The distribution of nonconformity scores across the calibration set, with three example observations placed on it.

Figure 1.7 shows absolute residuals for 200 calibration observations. The dashed line marks a cutoff, \(\hat q\), selected from these scores.

1.7 Conformal p-values

For a new patient, suppose \(\hat f(x_*)=20\) days. A candidate outcome of 22 has score \(|22-20|=2\).

Compare this score with the calibration scores in Figure 1.7. A candidate far from 20 has a large score. If few calibration scores are at least that large, the candidate is unusual relative to the calibration data.

A conformal p-value is based on the fraction of calibration scores at least as large as the candidate score, with the finite-sample adjustment given in the mathematics chapter. Large values indicate that the candidate is compatible with the calibration scores. Small values indicate that it is unusual.

A curve of conformal p-value against candidate outcome y, peaking at 1 near y=20 and dropping toward 0 as the candidate moves away in either direction. A horizontal dashed line marks alpha=0.10. A shaded region between about 15 and 25 marks the candidates whose p-value exceeds alpha.
Figure 1.8: The conformal p-value for candidate outcomes near and far from a new prediction of 20 days.

In Figure 1.8, candidates close to 20 have large p-values. The p-value falls as the candidate moves away from 20. Candidates with p-values at or below \(\alpha\) are excluded.

A conformal p-value is not the probability that a candidate is the true outcome and is not a Bayesian posterior probability. It ranks the candidate against the calibration scores.

A prediction interval or set keeps candidates with conformal p-values above \(\alpha\). With the absolute-residual score, the retained regression candidates form an interval around the point prediction. Other scores can produce different shapes.

1.8 Coverage

A target error rate \(\alpha\) corresponds to target coverage \(1-\alpha\). Under exchangeability, a 90% conformal procedure is designed to include the outcome at least 90% of the time over repeated calibration and test observations.

Scatter plot of recovery time against severity score for 300 test patients, with a shaded prediction interval band around the fitted line. Most points, shown as green dots, fall inside the band. A minority, shown as red crosses, fall outside it.
Figure 1.9: Prediction intervals for 300 new test patients, with covered and missed observations marked separately.

In Figure 1.9, 268 of 300 test outcomes fall inside their intervals. Empirical coverage is 89.3%. A finite test sample need not produce exactly 90% coverage.

Histogram of empirical coverage measured across 400 repeated experiments, centered close to 90 percent but spread from about 70 percent to nearly 100 percent, with a vertical line at the 90 percent nominal target and another at the 90.0 percent average across repeats.
Figure 1.10: Empirical coverage across 400 repeated experiments, each using a freshly drawn calibration and test set.

Figure 1.10 shows 400 repetitions with new calibration and test samples. Coverage varies across repetitions because both samples are finite. Its average is close to 90%.

The guarantee concerns the marginal behavior of the procedure over repeated calibration and test observations. It does not assign a 90% posterior probability to one reported interval. For a fixed interval and observed outcome, the outcome is either covered or missed.

1.9 Exchangeability

The coverage guarantee requires the calibration observations and the new observation to be exchangeable.

Nine colored squares numbered 1 through 9 in their original order, and the same nine squares in a shuffled order below, connected by faint lines showing where each one moved. A caption reads: exchangeable, every ordering is equally plausible before we see the data.
Figure 1.11: Nine observations shown in their original order, and in one arbitrary shuffled order.

Data are exchangeable when their joint distribution does not change after reordering. Figure 1.11 represents this as a shuffle. Independent observations drawn from the same distribution are exchangeable, although exchangeability is a weaker condition than independence.

Exchangeability can fail when calibration data and future observations come from different populations or data-collection processes.

Two overlapping histograms of severity score. The calibration population is centered around 4, the deployment population is centered around 7.5, with only partial overlap between them.
Figure 1.12: A calibration population and a deployment population with different severity score distributions.

In Figure 1.12, the deployment patients have higher severity scores than the calibration patients. Standard split conformal coverage does not apply automatically because the two samples are not exchangeable. Study design, sampling, time, site, eligibility criteria, and measurement procedures should be checked before relying on the coverage guarantee.

1.10 Marginal versus conditional coverage

Standard split conformal prediction controls coverage averaged over the target population. It does not guarantee the same coverage at every predictor value or within every subgroup.

Bar chart with three bars: Group A at 96.2 percent coverage, Group B at 68.5 percent coverage, and Overall at 89.2 percent coverage, with a dashed line at the 90 percent nominal target close to the overall bar.
Figure 1.13: Overall coverage close to the 90% target, built from two groups whose individual coverage is very different.

In Figure 1.13, Group A has 96.2% coverage and Group B has 68.5% coverage. Pooled coverage is 89.2%. The overall estimate hides the low coverage in Group B.

Marginal coverage averages over the target population. Conditional coverage refers to coverage at particular predictor values or within defined groups. Subgroup estimates can reveal heterogeneity, but standard split conformal prediction does not guarantee them. Group-conditional methods address selected, pre-specified groups later in this chapter.

1.11 Coverage is not enough

Coverage can be increased by making every interval very wide, but the resulting intervals may provide little information.

Scatter plot with two shaded bands around the same fitted line. A wide gray band contains essentially every point, with coverage listed as 100 percent and mean width 44. A narrower blue band contains most points, with coverage listed as 90 percent and mean width 10.
Figure 1.14: A trivially wide interval and a properly calibrated interval, both containing enough test observations to look valid on coverage alone.

In Figure 1.14, the gray band covers every test outcome but has mean width 44. The blue band reaches 90% coverage with mean width 10. Coverage should therefore be reported with interval width or prediction-set size.

Validity concerns coverage. Efficiency concerns how narrow the intervals or how small the prediction sets are. Both should be evaluated.

1.12 Homoscedastic versus heteroscedastic data

A constant-width interval may work when outcome variability is similar across the predictor space, called homoscedasticity. When variability changes with the predictors, the data are heteroscedastic and a constant width may be inefficient or poorly balanced across regions.

Scatter plot of recovery time against severity score, with variability visibly increasing at higher severity. A constant-width shaded band is overlaid. At low severity the band is far wider than the data require. At high severity, several points fall outside it.
Figure 1.15: One constant interval width applied to data whose true variability grows with severity.

In Figure 1.15, outcome variability increases with severity. The constant-width interval is unnecessarily wide at low severity and too narrow at high severity. Overall coverage is 89.8%, but coverage is uneven across the predictor range.

1.13 Conformalized quantile regression

Conformalized quantile regression (CQR) allows interval width to vary with the predictors.

CQR first estimates lower and upper conditional quantiles. It then uses held-out calibration scores to adjust both bounds. Under exchangeability, this adjustment provides marginal coverage while retaining widths that vary across observations. It does not guarantee conditional coverage.

The same scatter plot as the constant-width figure, now with a shaded band that is narrow at low severity and grows steadily wider at high severity, tracking the true spread of the data more closely.
Figure 1.16: An adaptive interval on the same heteroscedastic data, its width growing with severity.

In Figure 1.16, the interval widens with severity and has 89.4% overall coverage. CQR is not always narrower than a constant-width interval. Its benefit depends on how well the quantile models learn changes in the outcome distribution.

1.14 Classification methods

Conformal classification returns a set of retained classes. LAC, APS, and RAPS use different scores to construct that set.

1.14.1 LAC

LAC uses the score \(1-\hat\pi_y(x)\), where \(\hat\pi_y(x)\) is the fitted probability of candidate class \(y\). A class with high fitted probability has a small score.

Bar chart with three classes, A at 0.51, B at 0.47, and C at 0.02. A dashed calibrated threshold line sits at 0.45. A and B, above the line, are retained. C, below it, is not.
Figure 1.17: LAC applied to the opening classification example. Classes with probability above the calibrated threshold are retained.

In Figure 1.17, the equivalent probability threshold is 0.45. Classes A and B exceed it and C does not, so the set is \(\{A,B\}\). LAC can return a singleton, several classes, or an empty set, depending on the calibrated cutoff and fitted probabilities.

1.14.2 APS

Adaptive prediction sets (APS) use the ranked class probabilities and their cumulative sum.

Bar chart of four classes ranked by probability, 0.45, 0.30, 0.20, 0.05, with a cumulative probability curve overlaid rising to 0.45, 0.75, 0.95, 1.00. A dashed threshold line sits at 0.85. The first three classes, whose cumulative probability first clears the threshold, are highlighted.
Figure 1.18: APS applied to a four-class example. Classes are added, most likely first, until the cumulative probability clears a calibrated threshold.

In Figure 1.18, the ranked probabilities are 0.45, 0.30, 0.20, and 0.05. Their cumulative values are 0.45, 0.75, 0.95, and 1.00. The cumulative total first exceeds the illustrated threshold of 0.85 after the third class, so the set is \(\{1,2,3\}\). APS tends to return smaller sets when probability is concentrated and larger sets when it is spread across classes.

1.14.3 RAPS

With many classes, APS can include a long tail of classes with small individual probabilities. RAPS adds a penalty based on class rank to discourage large sets.

Two bar charts of the same fifteen ranked class probabilities, decreasing from about 0.22 down to 0.004. In the left panel, APS includes the first nine classes. In the right panel, RAPS includes only the first five.
Figure 1.19: APS and RAPS applied to the same fifteen-class probability vector. RAPS penalizes travelling far down the ranked list, producing a smaller set.

In Figure 1.19, APS retains nine classes and RAPS retains five. RAPS does not always produce smaller sets. Its result depends on the regularization settings, calibration data, and probability distribution.

1.14.4 Prediction-set size

Set size should be examined across the test sample, not only for one observation.

Bar chart of prediction set sizes 0 through 4. No observations receive an empty set. Most receive size 2, a smaller number receive size 1 or size 3, and very few receive size 4.
Figure 1.20: Prediction set sizes across many test observations, from a five-class conformal classifier at 90% target coverage.

Figure 1.20 shows APS set sizes in a five-class example with a 90% target. Most sets contain two classes. Some contain one or three, and a few contain four. Report the distribution together with mean set size and the fractions of empty and singleton sets.

1.15 Mondrian and group-conditional conformal prediction

Mondrian, or group-conditional, conformal prediction calibrates separately within pre-defined groups. It can provide group-specific coverage under suitable exchangeability assumptions within each group.

Bar chart with four bars: pooled data across all hospitals at 690 observations, Hospital A at 500, Hospital B at 150, and Hospital C at 40, with an annotation over Hospital C noting that it has too few observations for a stable cutoff.
Figure 1.21: Calibration observations available overall, and within three individual hospitals.

In Figure 1.21, each hospital receives its own cutoff. Hospital A has 500 calibration observations, while Hospital C has 40. The cutoff for Hospital C will have coarser rank resolution and greater sampling variability. Finer groups leave fewer calibration observations in each group.

The guarantee applies to the chosen groups, not to every predictor value or unexamined subgroup. Groups should be selected before final evaluation and must contain enough calibration observations for the target error rate.

1.16 Split conformal, full conformal, Jackknife+ and CV+

Split conformal prediction fits one model and uses a separate calibration sample. Other constructions use the available data differently.

Flow diagram. All data splits into training data and calibration data. Training data leads to fit model once. Calibration data leads to residuals to cutoff. Both lead into a prediction interval.
Figure 1.22: The split conformal workflow: one model fit, one calibration pass.

Figure 1.22 shows one model fit followed by one calibration step.

Full conformal prediction considers candidate outcomes one at a time. For each candidate, it augments the data, refits the model, and compares scores symmetrically across observations. This can require many model fits for every new prediction.

Jackknife+ fits \(n\) leave-one-out models. Each observation supplies an out-of-sample residual, and each fitted model predicts the new observation.

Flow diagram. All n observations lead to n leave-one-out model fits, each producing a residual and a prediction for the new observation. These are combined into a single interval.
Figure 1.23: The Jackknife+ workflow: one model refit per left-out observation, combined into a single interval.

Figure 1.23 shows how the \(n\) residuals and \(n\) predictions are combined into one interval. This construction differs from repeating split conformal without a fixed split.

CV+ uses \(K\) folds instead of \(n\) leave-one-out fits.

Flow diagram. All data, split into K folds, leads to K model fits, each holding out one fold and fitting on the rest, producing out-of-fold residuals and predictions. These are combined into a single interval.
Figure 1.24: The CV+ workflow: K model fits, one per fold, combined into a single interval.

In Figure 1.24, each held-out fold supplies out-of-fold residuals and its fitted model predicts the new observation.

Method Data usage Model fits Computational cost Main advantage Main limitation
Split conformal One training/calibration split 1 Low Simple and fast Reserves data for calibration alone
Full conformal Every observation, repeatedly Many, per candidate outcome Very high No fixed calibration split Usually impractical beyond small problems
Jackknife+ Every observation, leave-one-out \(n\) High Avoids a fixed, possibly unlucky split Expensive when \(n\) is large
CV+ Every observation, in \(K\) folds \(K\) Moderate Most of Jackknife+’s benefit, far fewer fits Some sensitivity to the choice of \(K\)

Split conformal is usually the simplest starting point. Jackknife+ and CV+ use the data more fully but require more computation. Full conformal is often impractical outside small or specialized problems.

1.17 Distribution shift and time series

Time ordering, dependence, and population change can invalidate the exchangeability assumption used by standard split conformal prediction.

Two stacked time series plots. Top: a static interval band computed from the first 90 time points, covering points well before that mark but missing almost every point after it. Bottom: an interval band whose width increases after repeated misses, again covering points well before the shift and recovering coverage after it, though wider than before.
Figure 1.25: A static conformal interval, calibrated before a change in the underlying process, fails after that change, while an interval that adapts over time recovers.

In Figure 1.25, the process level changes after calibration. The static interval covers 86.7% of observations before the change and none afterward. An adaptive interval widens after repeated misses and recovers some coverage, at the cost of greater width.

Covariate shift changes the predictor distribution while retaining the conditional outcome distribution. Concept drift changes the relationship between predictors and outcome. Time dependence makes nearby observations dependent and their ordering informative.

Weighted conformal prediction adjusts calibration scores using estimated or known density ratios under covariate shift. Rolling calibration uses recent observations and discards older ones. EnbPI and Adaptive Conformal Inference (ACI) update intervals using recent prediction errors. These methods address different forms of shift or dependence.

Their guarantees differ from ordinary split conformal coverage and require additional assumptions. A standard exchangeable-data guarantee should not be reported when known shift or dependence violates its conditions.

1.18 When conformal prediction is useful

Conformal prediction is useful when:

  • a fitted model needs prediction intervals or prediction sets
  • a parametric error distribution is difficult to justify
  • a pre-specified marginal error rate is meaningful
  • calibration observations and future observations can reasonably be treated as exchangeable

1.19 When conformal prediction is less suitable

Conformal prediction is less suitable when:

  • too few observations remain for stable calibration
  • calibration and deployment populations differ substantially
  • dependence or time ordering is ignored
  • the requirement is coverage for every individual or every subgroup
  • rare classes or groups have too few calibration observations

A weak base model often produces wide intervals or large prediction sets. Conformal calibration controls coverage under its assumptions, but it does not make the underlying predictions more accurate.