Unit 12 of 12 · about 5 hours · implement

Prediction intervals, conformal coverage and selective risk

A confidence interval for an average effect, a prediction interval for a future outcome and an abstention policy answer different questions. Their guarantees must not be borrowed from one another.

You'll be able to

  • Implement split-conformal prediction with separate fitting, calibration and evaluation data.
  • Audit the finite-sample quantile rank and distinguish marginal from conditional coverage.
  • Measure width, slice coverage and covariate-shift failure alongside selective risk and acceptance coverage.

Covers

Prediction intervals and conformal coverageSelective risk, coverage and abstention
1

Read

In this order, only the parts listed

0 of 2 done

  1. Angelopoulos and Bates: coverage, adaptivity and selective accuracyA Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification

    Version 6: Section 1.1 and Theorem 1, pages 5 to 6; Sections 3.1 to 3.3, pages 12 to 16; Sections 4.5 to 4.6, pages 20 to 22; Section 5.5, pages 25 to 26

    Use absolute-residual split regression for implementation. Read the selective-accuracy distinction, not the full Learn then Test appendix. Check the quantile rank independently rather than copying the higher code convention.

  2. MAPIE 1.5: split-conformal regression APIMAPIE 1.5 - Prediction Sets and Intervals

    mapie.regression.SplitConformalRegressor: constructor, fit, conformalize, predict_interval, and returned interval shape

    Skip other regressors. Set prefit=False explicitly for a new estimator; the default assumes an already fitted one.

2

Focus on

  • A prediction interval covers a future outcome, not the population mean or model parameter. Split conformal with a frozen score and exchangeable calibration/test examples gives a marginal guarantee over calibration and a new example; it does not promise coverage at every feature value or for this one case.
  • For calibration size , use order-statistic rank , retaining ties conservatively. If the required rank exceeds the available scores, finite bounds cannot supply that rank rule; use the appropriate infinite-set convention rather than clipping silently.
  • Absolute-residual intervals have constant width for a fixed model and calibration set, even when noise grows with a feature. Report overall and predeclared-slice coverage with width. Covariate shift can break coverage while the conditional outcome law stays fixed; weighting needs suitable assumptions and weights, not just more old-population calibration. Conditional-law drift is a different failure.
  • Selective coverage is the probability of accepting a case, not prediction-set coverage. Selective risk is expected loss conditional on acceptance. A higher confidence threshold need not monotonically improve risk, and accepted risk is undefined if no cases are accepted. Threshold selection needs separate data or a valid risk-control procedure, not inspection of the final test curve.
Common mistakes · 3
  • Reading 90% marginal coverage as a 90% conditional probability for each case or subgroup.
  • Selecting the score, calibration method or abstention threshold on the final evaluation set.
  • Calling zero accepted cases zero risk, confusing the two coverage denominators, or hiding an adjacent quantile convention's rank and conservatism.
3

Try it yourself

Closed-book, before checking anything

Use NumPy 2.5.4, scikit-learn 1.9.1 and MAPIE 1.5.0 on CPU. Set rng=np.random.default_rng(2026) and define each sample by drawing x=rng.uniform(lo,1,size=(n,1)), then y=2*x[:,0]+rng.normal(size=n)*(.1+2*x[:,0]). In order, draw 300 training and 300 calibration examples with lo=0. Import SplitConformalRegressor from mapie.regression and LinearRegression from sklearn.linear_model; instantiate SplitConformalRegressor(LinearRegression(),confidence_level=.9,prefit=False), then call fit and conformalize on their separate sets. Draw 2000 test examples with lo=0, then 2000 with lo=.75, without refitting or recalibrating. predict_interval returns points and bounds of shape (2000,2,1); use columns [:,0,0] and [:,1,0]. A CPU run gave coverages 0.9185 and 0.7825 and identical mean width 4.590596; report binomial test uncertainty conditional on this calibration, plus predeclared low/high-feature counts and coverage, rather than demand exact rates. Independently verify rank 271 for 300 scores at 90%: on scores 1 through 300, np.quantile(scores,271/300,method='inverted_cdf') returns 271 while method='higher' returns 272. Finally use fixed confidences [.9,.8,.6,.55] and zero-one losses [0,1,0,1]: acceptance at thresholds 0, .7, .85 and .95 gives coverages 1, .5, .25 and 0 with accepted risks .5, .5, 0 and undefined. These four cases are arithmetic, not a risk guarantee.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why does the shifted test have the same interval width but worse coverage?Answer

    The fitted absolute-residual rule uses one calibration radius everywhere. The shift concentrates tests where noise is larger, while the old radius stays fixed. Calibration and test scores are no longer exchangeable.

  2. 2.Does a binomial interval from one test set validate the unconditional conformal theorem?Answer

    No. It describes finite test-sample uncertainty conditional on this fitted and calibrated rule. Assessing variability over calibration sets requires repeated independent calibration experiments.

  3. 3.Does selecting singleton conformal sets guarantee low accepted error?Answer

    Not from marginal set coverage alone. Conditioning on acceptance changes the denominator; selective error needs its own analysis and, for a guarantee, an appropriate selection-aware procedure.

You're done when

Your split isolation, bound shape, rank and selective table checks pass, and you can defend the coverage scope and explain the shift failure without promising conditional or selective guarantees.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 18 more in the section
  • A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty QuantificationAngelopoulos and Bates · required

    Read v6 Section 1 (marginal coverage, Theorem 1), 3.1 to 3.3 (adaptivity, marginal versus conditional coverage, calibration size, checking coverage), 4.5 to 4.6 (shift and drift) and 5.5 (selective classification). The conformal quantile uses rank : 271 for and . np.quantile with method="higher" at 271/300 returns the 272nd score, conservative but not the stated rule; library conventions matter. Distribution-free is not assumption-free: the guarantee is marginal and needs exchangeability.

  • MAPIE 1.5 - Prediction Sets and IntervalsMAPIE · support

    Use the v1.5 API: SplitConformalRegressor and SplitConformalClassifier (confidence_level=0.9; .fit on training data, .conformalize on separate calibration data, then .predict_interval or .predict_set) and the cross-conformal classes with .fit_conformalize. The split classes default to prefit=True. Older MapieRegressor examples with alpha= are a retired interface. Report coverage with width or set size overall and per predeclared slice, then shift only the covariates and show coverage fall while the interval width stays the same.

Also in this section

  • MS&E 226 - Fundamentals of Data ScienceStanford University · primary

    Assign a narrow route through the 2025 lecture PDFs at https://web.stanford.edu/class/msande226/2025/lectures/ (PDF page numbers, overlays included): Lecture 10 pp. 18 to 22 (limitations and assumptions), 35 to 38 (block bootstrap) and 40 to 43 (heteroskedastic regression), with Example 4 of lecture10.Rmd; Lecture 12 pp. 18 to 26 (Benjamini-Hochberg) and 28 to 34 (post-selection inference and sample splitting); Lecture 16 pp. 32 to 35, 37 to 42 and 44 to 53 (prior mismatch, the winner's curse, utility-based rollout). Lectures 8 to 11 mostly repeat the entry gate. The notes page mixes 2026 and 2025 lectures, and some data needs a Stanford account.

  • Introduction to ValidityWilliam Trochim, Research Methods Knowledge Base · required

    Read the four validity types as a cumulative staircase: conclusion validity (is there a relationship), internal validity (is it causal), construct validity (did the treatment and measure capture the intended constructs) and external validity (to which persons, places and times does it generalize), each with its threats. The page frames them for causal studies; for a predictive claim, map them explicitly to the statistics, to whether the comparison isolates the claimed cause, to whether the label and metric measure the intended quantity, and to the populations the claim reaches. The host is a survey vendor; ignore the product material around the text.

  • Accounting for Variance in Machine Learning BenchmarksBouthillier et al., MLSys 2021 · required

    Read v1 Section 2 with Figures 1 to 3 (sources of variance: data splits, initialization, data order, hyperparameter search), Section 3.2 with Figure 4 and Section 5. Retuning per repetition costs fits and fixing the search costs , and the two estimate different targets. Allocate repetitions across sources instead of adding seeds after one successful search. "Control false detections at a rate of 95%" in 3.1 means a 95% confidence convention, not a false-detection rate.

  • Deep Reinforcement Learning at the Edge of the Statistical PrecipiceAgarwal et al., NeurIPS 2021 · required

    Read v4 Sections 4.1 to 4.3 with Figures 5 to 9: stratified bootstrap intervals, performance profiles, the interquartile mean (drop the bottom and top 25% of runs, average the middle 50%), optimality gap and probability of improvement; Figure 5 shows evaluator choice explaining apparent gains. Practise on runs-by-tasks score arrays with the rliable library (https://github.com/google-research/rliable), no RL training. Three-run intervals can undercover, profile bands are pointwise, and IQM can hide catastrophic tails.

  • On Calibration of Modern Neural NetworksGuo, Pleiss, Sun and Weinberger, ICML 2017 · required

    Read Section 2 (calibration, reliability diagrams and ECE, Eq. 3 with equal-width bins over top-label confidence), the temperature scaling paragraph (Eq. 8) and Table 1, which uses M = 15 bins. Temperature is fit on validation NLL, not on test ECE, and the paper assumes calibration and test data share a distribution.

  • Measuring Calibration in Deep LearningNixon et al. · required

    Read v2 Sections 3.1 to 3.4 (non-maximum classes ignored, fixed ranges, bias and variance, static-bin pathologies) and 5.3 (sensitivity to the bin count). Predeclare the calibration functional and bins, report counts, classwise curves, NLL or Brier and the decision loss, and check that conclusions survive adaptive bins. Choosing the bin count after seeing which model wins is a forking path.

  • SciPy Statistics - Resampling and Monte Carlo MethodsSciPy · required

    Use the API pages for scipy.stats.bootstrap (paired=True resamples one index array for every input), permutation_test (permutation_type="samples" swaps labels within matched observations; "pairings" tests association, not a paired mean difference) and monte_carlo_test, with an explicit rng and batch. Vectorized statistics must reduce only axis. Justify the null invariance and the resampling unit, rebuild one interval from blank NumPy code, and show a user- or block-level analysis beside a naive event-level one. A paired per-example analysis conditions on the fitted models and excludes training and search variability; never print a Monte Carlo p-value as zero.

  • Always Valid Inference: Continuous Monitoring of A/B TestsJohari, Pekelis and Walsh · required

    Read v3 Section 4 (Definition 1, Eq. 3, pp. 13 to 15): an always-valid p-value satisfies for every stopping time , which is stronger than validity at each fixed sample size. Section 5's mSPRT is depth. Always validity holds under the assumed model and filtration; it does not repair assignment, metric changes or post hoc hypotheses. The final version is Operations Research 70(3), 2022, with Koomen added as an author and different numbering.

  • Controlling the False Discovery Rate: a Practical and Powerful Approach to Multiple TestingBenjamini and Hochberg, JRSS B 1995 · required

    Read 2.1 (FDR as the expectation of the false-discovery proportion, zero when nothing is rejected) and 3.1 (the step-up rule: find the largest with , reject all ranks through ; Theorem 1 assumes independent statistics), then the 15-outcome example in 3.2. At 0.05 the example gives three Bonferroni or Holm rejections against four for BH. This author copy is a scan whose PDF page 1 is a JSTOR cover, so printed p. 291 is PDF page 4. Choose FWER or FDR before seeing which admits your favourite result.

  • Are We Learning Yet? A Meta Review of Evaluation Failures Across Machine LearningLiao, Taori, Raji and Schmidt, NeurIPS 2021 Datasets and Benchmarks · support

    Read Sections 2 to 4: a taxonomy drawn from 107 analysis papers. Internal validity covers failures within one benchmark (implementation variation, test-set reuse, inadequate baselines) and external validity covers whether progress transfers (metric and dataset misalignment, shift, human comparisons). These definitions are narrower than the classical four types; use the sections as ML case material for each threat you list.

  • Conformal Prediction Under Covariate ShiftTibshirani, Barber, Candes and Ramdas, NeurIPS 2019 · support

    Read v3 Section 2 and Figure 2: weighted conformal prediction repairs coverage when only the covariate distribution changes, given the likelihood ratio and support of the test covariates. Estimated weights are an approximation of that theorem, severe shift leaves little effective calibration data, and no weighting repairs a changed conditional distribution or unsupported regions.

  • statsmodels - Power and Multiple Testingstatsmodels · support

    Use TTestIndPower for independent arms and TTestPower for paired differences (solve_power), and multipletests for the predeclared family. For , 80% power and two-sided 0.05 the independent design needs 394 per arm and the paired one 199 pairs, but the two standardize by different variances. Assessed work is the design justification: a raw-unit minimum effect, a variance grid, costs and a design effect for clustered data, never post hoc observed power.

  • Applied Science and ML Research CheckpointRoadmap-Final · support

    Use the named bullets as a closed-note audit: Formulate and reason 1 to 2 (estimand, unit, timing, thresholds, stop conditions, fair budgets), Reproduce and experiment 2 to 4 (failed runs, negative controls, versioned raw output) and Debug and defend 2 (selected runs and slices, invalid statistics). It defines evidence to submit, not a teaching route or a validated mastery score.

  • How Not To Run an A/B TestEvan Miller · optional

    A memorable peeking example (Example; How big of a problem is this?; What can be done?). Correct its language: a p-value is not the chance that a difference is due to luck or of beating the original. Reproduce the failure yourself: under a true null, testing at every one of 49 looks rejects far more often than 5%, and a Bonferroni repair is valid but inefficient. Johari's Definition 1 is the authority, not this page's table.

  • 18.650 - Statistics for ApplicationsMIT OpenCourseWare · depth

    Derivation repair only: sessions 7 to 10 on parametric hypothesis testing (the PDF calls them Chapter 5) and sessions 17 to 18 on Bayesian statistics (PDF Chapter 8), when the investigation needs a derivation of its test or posterior rather than an API call. It has no sequential, seed-variance, conformal or calibration-limits material.

  • Approximate Statistical Tests for Comparing Supervised Classification Learning AlgorithmsThomas Dietterich, Neural Computation 1998 · depth

    When the claim compares learning algorithms rather than two fitted classifiers: Section 1 (which question each test answers), 3.1 (McNemar ignores training-set and internal randomness) and 3.5 (5x2cv divides the first difference by the root mean of five within-repetition variances, not a t-test on ten scores). Its independence assumptions are admittedly violated.

  • Statistical Comparisons of Classifiers over Multiple Data SetsJanez Demsar, JMLR 2006 · depth

    Only for a multi-dataset claim: 3.1.3 (Wilcoxon signed-rank for two classifiers) and 3.2.2 (Friedman with post-hoc tests, critical difference ). Define the task population first. Average ranks discard magnitudes and change with the competitor set, and a non-significant difference is not equivalence.

  • The Difference Between Significant and Not Significant is not Itself Statistically SignificantAndrew Gelman and Hal Stern, The American Statistician 60(4), 2006 · required

    Sections 1, 2 and 5, printed pages 328 to 329 and 331: compare effects directly, not their significance flags. This fills the pool's subgroup-interaction inference gap; Agarwal's task profiles and Nixon's classwise calibration do not supply that contrast. In Section 2, the independent 25 and 10 estimates each have SE 10, so their difference has SE square root of 200. The first estimate's two-sided normal p-value is about 0.0124, so the prose's 1% claim holds only one-sided (about 0.0062).