7 routes42 sections324 units

Unit 5.6 · about 4 h

165 / 324

Paired bootstrap, permutation tests and multiplicity

Two models sharing a test set produce correlated scores. Unpaired uncertainty is wider than honest, and unadjusted selection is optimistic.

  • implement
  • measure

You can now

  • Report a paired bootstrap interval for a model difference with the resampling unit matched to the comparison.
  • Run a paired permutation test with the correct permutation type and state its null in words.
  • Report an effect size beside every p-value and adjust for multiplicity with the search history on record.

Covers

  • Paired bootstrap intervals, permutation tests and effect sizes
  • Multiplicity, search history and winner's curse

Study, in this order

3 steps

  1. The Bootstrap and paired-sample permutation tests
    SciPy - Resampling and Monte Carlo methods tutorials

    The notebooks linked from this page: Tutorial 3 (The Bootstrap: scipy.stats.bootstrap with paired=True, BCa and percentile intervals, standard errors) and Tutorial 2b (Paired-Sample Permutation Tests: permutation_test with permutation_type='samples')

    Depth · Stay inside Tutorials 2b and 3. The independent-sample and Monte Carlo tutorials solve different comparisons.

  2. ISLP Chapter 5 lab: the bootstrap standard error
    ISLP - resampling and multiple testing

    The Bootstrap (Portfolio \(\alpha\) standard error 0.0912 via boot_SE with B=1000 and seed 0, then the linear-regression coefficient SEs)

  3. ISLP Chapter 13 lab: FWER, FDR and the double-dip
    ISLP - resampling and multiple testing

    Family-Wise Error Rate (Bonferroni rejects only Manager One; Holm rejects Managers One and Three at FWER 0.05; the best-versus-worst paired test at \(p = 0.038\) rises to 0.186 under Tukey's method) and False Discovery Rate (Benjamini-Hochberg on all 2,000 managers)

Focus on

  • Resample pairs, not models: one index stream (paired=True) must score both models, or shared example difficulty becomes noise.
  • The paired-difference test is permutation_type='samples' (sign flips within pairs). 'pairings' tests association instead; 'independent' shuffles labels across groups.
  • Pairing shrinks intervals. In the reproduce simulation a 4.8-point gap on 500 items has a paired 95% interval about 0.038 wide, against about 0.120 when each model is resampled on its own, which then covers zero.
  • Every tuned, selected or re-run comparison spends error budget. Record the search history and report Holm (FWER) or BH (FDR) adjustments beside raw p-values and effect sizes.

Reproduce closed-book

Closed-book, implement a paired bootstrap for an accuracy difference (one index stream for both models, 9999 resamples, percentile interval) plus a paired permutation test. Simulate shared difficulty: default_rng(0), \(u\) uniform on 500 items, model \(A\) right when \(u < 0.70\) and model \(B\) when \(u < 0.65\), so \(B\)'s hits are a subset of \(A\)'s, the strongest pairing. Accuracies are 0.662 and 0.614; expect a paired interval near [0.030, 0.068] against near [-0.010, 0.110] when each model is resampled independently.

Traps

  • Bootstrapping each model's scores with its own rng stream. Unpaired resampling destroys the pairing and inflates the interval.
  • Using permutation_type='pairings' (or 'independent') for a paired model comparison. That tests correlation (or cross-group exchangeability), not the mean paired difference.
  • Reporting the winning p-value after many seeds, splits or metrics. In the ISLP Fund lab the best-versus-worst managers, picked after looking, give \(p = 0.038\); Tukey's method over the implied 10 comparisons raises it to 0.186.

Practice

ISLP Ch05 lab: bootstrap standard errors

Reproduce \(\alpha\) SE 0.0912 (B=1000, seed 0) and the OLS bootstrap SEs from The Bootstrap

ISLP Ch13 lab: Bonferroni, Holm and Benjamini-Hochberg

Reproduce the Bonferroni and Holm verdicts (only Manager One, then One plus Three at FWER 0.05), the Tukey adjustment from 0.038 to 0.186, and the Benjamini-Hochberg rejections on all 2,000 managers

Run both labs before your own paired comparison, then report it with an effect size and a comparison count.

Self-test

  1. Two models share the test set. Why must the bootstrap indices be identical for both?

  2. Which permutation_type tests a paired accuracy difference, and what does it shuffle?

  3. Your paired interval is [0.030, 0.068] and the permutation \(p\) is 0.0002 from 9999 resamples. What do you report?

  4. After 20 metric looks, one comparison gives \(p = 0.03\). Ship it?

Completion criterion

Stop when

Your paired bootstrap and permutation test agree on a model comparison, the interval uses one index stream, and every p-value ships with an effect size and a comparison count.

Mark passed, then open 5.7 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • ISLP - resampling and multiple testing
    James, Witten, Hastie, Tibshirani and Taylorrequiredtheory
    Use Chapter 5 and the relevant selection-history parts of Chapter 13 with their Python labs. Connect resampling to uncertainty and multiplicity without repeating the full statistics stage.
  • SciPy - Resampling and Monte Carlo methods tutorials
    SciPy developersreferencereference
    Work the notebooks linked from this page: Tutorial 3 (The Bootstrap) with scipy.stats.bootstrap, including paired=True, and Tutorial 2b (Paired-Sample Permutation Tests) with permutation_test and permutation_type='samples'. Keep one resampling index stream across compared models.

Also in this section

  • scikit-learn - model selection and evaluation route
    scikit-learnprimarycourse
    Follow Cross-validation, Hyperparameter tuning, Decision threshold tuning, Metrics and scoring, Probability calibration, Validation curves, Permutation importance and Common Pitfalls. Retain raw predictions and independently hand-check central metrics.
  • Classical ML Scientific Investigation
    Roadmap-Finalreferenceassessment
    Use Core requirements, architecture constraints, Milestones A-F and failure injection as the standard for end-to-end evidence. The full project remains a later capstone route.
  • D2L - Environment and Distribution Shift
    D2L authorssupporttheory
    Read 4.7, then construct one controlled covariate, label and concept shift. Record what changes, which signal detects it and what response the evidence supports.
  • Deep-ML candidate - evaluation problems
    Deep-MLoptionalpractice
    After the platform admission check, use at most one of 18 K-Fold CV, 260 Expected Calibration Error, 276 ROC, 277 AUC or 840 Stratified K-Fold. Hand-checked local metrics remain the evidence.
  • El-Yaniv and Wiener - On the Foundations of Noise-free Selective Classification
    JMLRreferencereference
    Read the Abstract and Section 2 (Preliminary Definitions: Definitions 1 and 2 for coverage and selective risk) for the risk-coverage tradeoff. Stop before the noise-free learning bounds.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels