Chapter 4 · Resampling Methods

ISLR Chapter 5 — spending data to buy an honest error estimate

You have one sample and two competing needs: to fit the model and to judge it. Use the same rows for both and the judgement flatters the fit. Resampling is the machinery for holding those needs apart.

Cross-validation splits the data repeatedly, fits on part and evaluates on the rest, and averages. The bootstrap does something different: it resamples with replacement to approximate the sampling distribution of any statistic, including ones with no closed-form standard error. Between them they cover most of what you need to say honestly how good a model is and how uncertain a number is.

What you should take away

  • The validation-set approach, and why its estimate is both variable and pessimistic
  • Leave-one-out cross-validation, and the shortcut formula for linear models
  • \(k\)-fold cross-validation, and why \(k = 5\) or \(10\) is the usual compromise
  • The bias–variance trade-off in the error estimate itself, not just the model
  • Cross-validation for tuning versus cross-validation for reporting performance
  • The bootstrap for standard errors when theory is unavailable or unbelievable

Slides

Labs

Rendered output: Bootstrapping · PSX cross-validation · PSX bootstrapping

scikit-learn puts all of this behind cross_val_score, KFold and LeaveOneOut. The danger is that convenience: it is easy to cross-validate the wrong thing. Fit the pre-processing inside the fold, not before it.

Readings

Data

ImportantThe most common mistake in this course

Selecting variables, tuning a parameter or standardising columns using the full dataset, and only then cross-validating. The held-out fold has already seen that information, and your error estimate is now fiction. Every choice made from the data belongs inside the resampling loop.

Back to top