Prediction Intervals and Split Conformal Prediction › Example
Machine Learning from ScratchAll chapters Prediction Intervals and Split Conformal Prediction › ExampleSection view · Sections in this chapter5 / 10 ↓
Reading tools Definitions, links & notes
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
A small numerical example makes the quantile convention concrete. Let us work through a complete split conformal calculation by hand with ten calibration points and a simple regression model, so that every index in the formula is visible.
We have fitted on a training set and evaluated it on a calibration set of points, obtaining absolute residuals. Sorted, they are
The largest residual is in the response units of this illustrative example. Suppose we want 90% coverage, so and . The index is
where:
- : the calibration set size
- : the miscoverage level, so is the nominal coverage
- : the ceiling index, which selects the -th smallest calibration score
Because , the conformal quantile is the largest observed residual, . A new input with gets the interval
If the realized value turns out to be , it is inside the interval and this particular point is covered. If , it is not; the interval width of is simply not enough to catch a miss that large. The marginal guarantee averages over calibration and fresh test draws; it does not certify this particular point.
With almost surely distinct exchangeable scores, the repeated-sample coverage for this rule is . With ties, that value is a lower bound. This is a statement about the procedure over calibration and test draws, not the conditional coverage of the particular ten residuals displayed above. At this level and calibration size, the rule selects the sample maximum.
Now compare an 80% interval, . Then
where:
- : the miscoverage level, so
- : the resulting index, so
- : the calibration set size, giving the rank lower bound ; equality holds for almost surely distinct exchangeable scores, while ties can, but need not, increase coverage
With , the same prediction becomes , narrower as expected, with guarantee .
The convention matters here. Suppose we had carelessly used instead. For that gives and , exactly the margin we should have used for the 80% interval. The reported interval would cover about of calibration points, matching the nominal level on the calibration data, yet its coverage of future points is only guaranteed at the lower level , not at the nominal . The shortfall comes from replacing with : the resulting index is too small by roughly one position, so at the effective guarantee falls below the nominal . The wrong index can appear correct on the data used to compute it.
Now the classification case. Suppose the same ten calibration points give scores , sorted:
At we again have
So , giving the probability threshold :
- : the resulting index, the tenth smallest calibration score
- : the conformal quantile, equal to
- : the calibrated probability threshold applied to each class
A new input with class probabilities yields the set : and clear the bar and does not. The set has size two. If the true label is , this set misses it. The marginal bound does not assign an error probability to this particular vector or set.
Consider a classifier that spreads its probability mass across all three labels. Suppose the probabilities for some input are . Since all three exceed , the prediction set is all three labels. That input is effectively unclassified, and the set says so. Conversely, an input with probabilities yields the singleton . Set size reports how many labels this score and calibrated threshold retain at that input. It does not supply a calibrated probability that a singleton is correct or prove that an empty set is out of distribution.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!