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
| Week | Lesson | What you’ll do |
|---|---|---|
| 1 | Prediction, loss, and generalization | Compare a flexible fit with a simple baseline on data it did not see. |
| 2 | Linear regression and influential observations | Measure how one high-leverage point changes the fitted slope. |
| 3 | Logistic regression and decision thresholds | Convert a probability into an action using the costs of mistakes. |
| 4 | Resampling and model selection | Put tuning and evaluation in different levels of cross-validation. |
| 5 | Bias, variance, and model flexibility | See why adding flexibility can raise prediction error. |
| 6 | Ridge, lasso, and elastic net | Inspect how each penalty treats strongly correlated features. |
| 7 | Splines and additive models | Build a curve from piecewise terms and inspect its slope on each side of a knot. |
| 8 | Trees, bagging, and random forests | Compare the effect of changing the training sample on a tree and a forest. |
| 9 | Boosting and early stopping | Pick the number of boosting rounds without opening the test set. |
| 10 | Margins, kernels, and local prediction | Compare linear, kernel, and nearest-neighbour decision rules. |
| 11 | Calibration and prediction uncertainty | Distinguish a calibrated forecast from a narrow interval for a mean. |
| 12 | Capstone · Compare three prediction rules | Choose a model under one evaluation protocol and quantify the cost of that choice. |