Statistical Learning

Measure generalization and compare models without letting the test set guide the choice.

Measure generalization and compare models without letting the test set guide the choice.

Before you start. Mathematical Statistics.

Use Python 3.12 for the examples. Install the dependencies with python -m pip install numpy scipy scikit-learn. Run each week as a separate script. Try the worked example on paper first, then change one assumption in the lab and explain the result. All datasets are small or generated locally.

The 12 weeks

WeekLessonWhat you’ll do
1Prediction, loss, and generalizationCompare a flexible fit with a simple baseline on data it did not see.
2Linear regression and influential observationsMeasure how one high-leverage point changes the fitted slope.
3Logistic regression and decision thresholdsConvert a probability into an action using the costs of mistakes.
4Resampling and model selectionPut tuning and evaluation in different levels of cross-validation.
5Bias, variance, and model flexibilitySee why adding flexibility can raise prediction error.
6Ridge, lasso, and elastic netInspect how each penalty treats strongly correlated features.
7Splines and additive modelsBuild a curve from piecewise terms and inspect its slope on each side of a knot.
8Trees, bagging, and random forestsCompare the effect of changing the training sample on a tree and a forest.
9Boosting and early stoppingPick the number of boosting rounds without opening the test set.
10Margins, kernels, and local predictionCompare linear, kernel, and nearest-neighbour decision rules.
11Calibration and prediction uncertaintyDistinguish a calibrated forecast from a narrow interval for a mean.
12Capstone · Compare three prediction rulesChoose a model under one evaluation protocol and quantify the cost of that choice.

Further reading · An Introduction to Statistical Learning