2.1 The learning setup: data, model, loss
1. Learn
Section titled “1. Learn”- Stanford CS229 (Autumn 2018) lectureslectures 1–2: Introduction, Linear Regression and Gradient Descent
- Stanford CS229 main notes (Ng, Ma)Part I, chapter 1 "Linear regression" opening (supervised learning setup)
- Understanding Deep Learning (Prince)chapter 2 Supervised learning (pp. 17–24)
2. Bridge
Section titled “2. Bridge”Every model in this course follows one recipe. You have a dataset datasetn training pairs of an input x_i and its target y_i. Rows of X are the inputs xᵢᵀ; y stacks the targets.Introduced in 2.1 The learning setup: data, model, loss. UDL writes I pairs {xᵢ, yᵢ}; CS229 writes m examples (x⁽ⁱ⁾, y⁽ⁱ⁾)., a model that maps an input to a prediction predictionThe model's output for input x with parameters θ. The hat marks an estimate.Introduced in 2.1 The learning setup: data, model, loss. UDL writes f[x, φ] with parameters φ; CS229 writes h_θ(x)., and a loss lossThe scalar we minimise; lower is better. Often an average over training examples.Introduced in 1.6 Optimization. that says how wrong the predictions are. Training means choosing the parameters parametersAll learnable parameters of a model, collected into one vector.Introduced in 1.6 Optimization. UDL uses φ (phi) for model parameters; CS229 and most papers use θ. that make the loss small, which is the optimization problem from module 1.6 (UDL ch. 2; CS229 notes, Part I). In this module the model is a polynomial, , and the loss is the mean squared error.
The goal is not a small loss on the training data. The goal is good predictions on new inputs from the same source. A flexible enough model can drive training error to zero by memorising the noise: a degree- polynomial passes exactly through points. That is overfitting: training error keeps falling while error on unseen data turns up (UDL §8.3). The polynomial overfit lab below shows both curves at once.
So you hold some data back. The test set is set aside before you start and used once, at the end, to estimate performance on new data. Every look you take at it while choosing a model leaks a little information into your choices, and the estimate becomes optimistic. Choices such as the degree are made on a separate validation set, or by cross-validation in module 2.5 (UDL §8.5; scikit-learn, Cross-validation).
All of this rests on the i.i.d. assumption: training and test examples are independent draws from the same distribution. It breaks in two common ways. Leakage means information about the test set reaches training: duplicated rows, features computed from the label, or preprocessing statistics computed on all the data before splitting (scikit-learn, Common pitfalls: data leakage). Distribution shift means the world the model is used in differs from the one it was trained on (UDL ch. 8 Notes, “Real-world performance”). No split can detect shift. You can only design your test set to look like the deployment you care about.
3. Explore
Section titled “3. Explore”Split data with a seeded permutation, build polynomial features, fit them by least squares (the closed form comes in 2.2), and sweep the degree to produce the train/test curves from the widget yourself.
stubs/m2_1_setup.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/m2_1_setup.py and run mlc check 2.1. The tests are identical; import the results on the progress page.
Locally: mlc check 2.1.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.