A delivery model predicts 12 minutes for the next order, and a dispatcher wants a range that will contain the actual delivery time with probability at least 80 percent. A confidence interval for the average delivery time does not answer this, because a single delivery varies around the average however well the average is known. Split conformal prediction builds such a range from the errors of a frozen model on a separate calibration set, with a guarantee that needs no assumption about the shape of the error distribution. This lesson constructs the interval step by step and states exactly what the guarantee assumes and what it does not promise.
Key terms
Prediction interval
Definition Let be a new case whose outcome has not been observed. A prediction interval with level , for , is an interval , computed from observed data and the new features but not from , such that
under stated assumptions, where the probability is taken over the data used to build the interval and the new case. A confidence interval targets a fixed quantity, such as the conditional mean or a model coefficient, while a prediction interval targets one random future outcome.
In plain words A confidence interval for a mean narrows as data accumulate, because the mean becomes better known. A prediction interval cannot narrow below the spread of individual outcomes, because even a perfectly known mean leaves each delivery free to vary around it. Whether the probability is computed over all new cases together or separately at each input is a further question, taken up under marginal coverage.
Example As a constructed assumption, let delivery times at some input be normal with mean 12 minutes and standard deviation 2 minutes, both known exactly. The central 80 percent prediction interval is , about minutes, with width about minutes, and no interval that has probability at least under this distribution is shorter. An 80 percent confidence interval for the mean, computed from 100 such deliveries with the standard deviation known, has half-width minutes.
Aleatoric and epistemic uncertainty
Definition For the given features write and . Aleatoric uncertainty is the variation of the outcome that remains even when the conditional distribution of given is known exactly. Epistemic uncertainty is uncertainty about that conditional distribution itself, such as the value of , arising from limited data, an imperfect model or limited knowledge. For squared loss and a prediction computed from data independent of the new outcome,
The first term is aleatoric. The second is the error of the learned function at , which is unknown in practice, and epistemic uncertainty is uncertainty about its size. More data or a better model with the same features can reduce the second term but not the first.
In plain words Aleatoric uncertainty is the noise that the chosen features cannot explain, and epistemic uncertainty is what the model has not yet learned. The boundary between them depends on the features. A previously unmeasured factor, such as whether a building has an elevator, can turn part of the apparent noise into predictable variation once it is recorded. The split conformal method below does not separate the two kinds. It calibrates one overall interval from observed errors, which contain both.
Example In the normal example above, the 2 minute standard deviation is aleatoric for those features, and more data with the same features would not reduce it. If the mean of 12 minutes had instead been estimated from a handful of deliveries, a different handful would give a different estimate, and that spread is epistemic. A prediction of minutes at an input where the true mean is 12 minutes has expected squared error squared minutes, of which 4 is noise and comes from the error in the fitted mean.
Conformity score
Definition A conformity score is a function , chosen before any calibration label is seen and computed with the frozen predictor , that measures how poorly an outcome agrees with the prediction at . Here a larger score means worse agreement. Many texts call a score with this direction a nonconformity score, and some use conformity scores in which larger means better, so a score is always given with its formula. For regression the usual choice is the absolute residual
Given a threshold , the prediction set at contains every with . For the absolute residual this is the interval from to , endpoints included, with the same width at every input. A scaled residual , with a positive spread estimate fitted on the fitting data, gives intervals that widen where outcomes are expected to vary more.
In plain words The score turns each calibration case into one number, in outcome units for the absolute residual. A score chosen after looking at the calibration residuals has been tuned on them, and the coverage argument below no longer applies to it. The absolute residual gives the same width everywhere, even when deliveries on some routes vary much more than on others.
Example Three constructed fitting cases have inputs 0, 1 and 2 and delivery times 2, 4 and 6 minutes. Least squares with an intercept gives the predictor , which fits them exactly, and it is frozen. Nine separate calibration cases have inputs 0 through 8, with the outcomes, predictions and scores below, all in minutes.
| Input | Outcome | Prediction | Score |
|---|---|---|---|
Sorted, the scores are 1, 1, 1, 2, 2, 2, 3, 4 and 5 minutes. Every calibration outcome lies above its prediction, so the frozen line underpredicts here. The absolute residual ignores the sign, which leaves the guarantee intact but puts half of each interval below the prediction, the side on which no calibration outcome fell. Switching to a shifted or one-sided score because of this pattern would tune the score on the calibration labels, so such a change belongs on the fitting data or on a separate set of cases.
Split conformal prediction
Definition Split conformal prediction builds a prediction interval from a frozen predictor and a separate calibration set. The development data are split into a fitting set and a calibration set of cases, with no case in both. The predictor is fitted and tuned on the fitting set only and then frozen. The calibration scores for are sorted as . For a miscoverage level in chosen in advance, the rank and the radius are
and the interval for a new input runs from to , endpoints included. Because , the rank is always between 1 and , and happens exactly when . Suppose that, given the fitting set, the calibration cases and the new case are exchangeable, and that and the score were fixed without using them. Then
If in addition the scores are distinct with probability one and , the coverage equals , which is less than .
In plain words The new case adds one score to the calibration scores. Under exchangeability every one of the cases is equally likely to hold any given rank, so with distinct scores the rank of the new score is uniform over . The new outcome is covered exactly when its score is at most , which means its rank is at most , an event with probability . Ties can only help, since a new score equal to the radius is covered. When no calibration score is large enough. Using the largest calibration score instead would give, with distinct scores, coverage only , which is below in that case, so the radius is infinite. Residuals on the fitting data cannot replace the calibration set, because the model was fitted to make them small.
Example For the nine calibration scores and , the target coverage is 80 percent, and gives . The eighth smallest score is 4 minutes, so . At the new input the frozen model predicts 12 minutes, and the interval is minutes with both endpoints included, a width of 8 minutes. An observed time of 16 minutes would be covered and one of minutes would not. The fitting residuals are all zero, and calibrating on them would give a radius of zero, an interval that covers none of the nine calibration outcomes. With instead, exceeds , and the radius is infinite. These rows are constructed to make each step checkable. They do not show that real deliveries are exchangeable or that the intervals cover 80 percent of them.
Exchangeability
Definition Random cases , here , are exchangeable if for every permutation of the reordered sequence has the same joint distribution as . Independent and identically distributed cases are exchangeable. Exchangeable cases need not be independent, as with draws without replacement from a finite pool. Split conformal prediction needs the calibration cases and the new case, so , to be exchangeable given the fitting data. Applying the same fixed score function to each of them then makes the scores exchangeable as well.
In plain words Exchangeability says that the order of the cases carries no information, so nothing marks the new case as different from the calibration cases. Drift over time breaks it, because later cases come from a different process than earlier ones. So does a new case from a population that the calibration set did not sample. Repeated cases from the same customers also need a design that accounts for their dependence. A distribution-free guarantee is not assumption-free. It drops assumptions about the shape of the distribution but keeps this one.
Example Suppose that after a change in operations every delivery takes 3 minutes longer than it would have before, while the frozen model and the radius of 4 minutes stay the same. If the new signed residuals behaved like the calibration residuals shifted by 3, they would be 4, 5, 4, 6, 5, 7, 4, 5 and 8 minutes. Only the three equal to 4 fall within the radius, a coverage of in this stand-in instead of at least . The rank argument fails because the new score is systematically larger than the calibration scores rather than equally likely to land at any rank.
Marginal coverage
Definition Marginal coverage is the probability
taken jointly over the calibration set and the new case. Split conformal prediction guarantees that it is at least under the conditions above. Stronger properties are not guaranteed. Conditional coverage would require the same bound given for every input , and coverage within each subgroup would require it given membership in the group, and either can fail. The coverage of one realized calibration set, the fraction of future cases covered once is fixed, is itself random. When the cases are independent and identically distributed, the scores have a continuous distribution and , this fraction follows a beta distribution with parameters and , whose mean is .
In plain words The guarantee is an average over everything random, the calibration set, the new input and the new outcome. It allows the interval to cover easy inputs too often and hard ones too rarely, or to serve a large group well and a small group poorly. For one calibration set the realized coverage can land above or below the target, especially when is small. Coverage and width measured on protected data, by subgroup and over time, show how the intervals behave where it matters.
Example Suppose 90 percent of a population has coverage and the other 10 percent has coverage . The overall coverage is , a valid 90 percent marginal statement alongside poor coverage for the small group. For calibration sets of cases with continuous scores and , so , the coverage of one calibration set follows a beta distribution with parameters 8 and 2. Its mean is , but it falls below for about 44 percent of calibration sets and below for about 7 percent.
Check yourself
- A frozen model has four calibration residuals 1, 1.5, 0.5 and 3 units, and its prediction for a new case is 7. With , find the rank , the radius and the interval.
Show the answer
Sorted, the residuals are , , and , and . The rank is
so the radius is the third smallest residual, . The interval is , with both endpoints included. With distinct exchangeable scores its marginal coverage is , exactly the target.
- Repeat the first question with . Why is the largest residual, 3, not a valid radius, and how many calibration cases would a finite radius at this level need?
Show the answer
The rank is , which exceeds , so the radius is infinite and the interval is the whole real line. A radius of 3 covers the new case exactly when its score ranks at most fourth among the five scores, which with distinct exchangeable scores has probability , short of the required .
A finite radius needs , which holds exactly when , that is when . For this means . With nine calibration cases the rank is , the radius is the largest of the nine scores, and the coverage with distinct scores is .
- A team fits a delivery model on data from January to June. It tries five hyperparameter settings and keeps the one whose calibration residuals give the narrowest interval, then computes the radius from those same residuals. It reports that the interval covers 90 percent of deliveries in every region in December, after a change of delivery routes. What is wrong with each part of the claim, and what would make it sound?
Show the answer
Choosing the setting by its calibration residuals uses the calibration labels for tuning, so the scores are no longer those of a predictor fixed without them, and the guarantee does not apply. Tuning belongs on the fitting data, for example by cross-validation inside the fitting set, followed by calibration on cases that took no part in it.
The December cases follow a route change, so they are not exchangeable with calibration cases from the first half of the year, and the rank argument says nothing about them. The calibration set should come from cases that represent the new conditions, and coverage should be monitored on later protected cases.
The guarantee is marginal, so it does not promise 90 percent in every region. Coverage within each region can be targeted by running the calibration separately in each region, which needs enough calibration cases per region and exchangeability within it, and the coverage and width by region should be reported from protected data.