Bias, Variance & Generalisation

Underfitting, overfitting, learning curves, regularisation and early stopping — the mechanics of why a model that memorised the training set looks perfect until it meets new data.

Bias and Variance
▶ lab

Every model is wrong in two ways at once: too simple to represent the pattern, or too flexible to ignore the noise. The gap between training and validation error tells you which.

Q · Two models both miss the target. One is systematically off in the same direction on every dataset, the other is right on average but swings wildly between training runs. Which one do you have, and what does that decide?
Overfitting
▶ lab

A model that memorises the noise in its training set scores perfectly on that set and poorly on the next one. Every route to a better training number is also a route to this.

Q · The training metric keeps improving as you add capacity, epochs and features, and the validation metric stopped improving a while ago. What has the model learned since then, and why does a leaked feature look like the opposite?
Underfitting
▶ lab

A model with too little capacity, or the wrong representation, misses structure that is plainly in the data. It is the honest failure — visible offline — and still the one most often fixed with the wrong tool.

Q · Training and validation error are both poor and nearly equal. More data does nothing. What is the model unable to express, and how do you know it is the model and not the labels?
Learning Curves
▶ lab

Error against training-set size, for training and validation together. The shape says whether more data, more capacity or better features is the fix — before any of them is tried.

Q · You can spend the next quarter labelling more data, or building a bigger model, or engineering features. Which one will move the validation number, and how can you know before spending it?
Regularisation
▶ lab

Every way of refusing part of the training fit: L1, L2, dropout, depth limits, shrinkage, early stopping. The strength is a hyperparameter, it is tuned on validation, and for the penalty forms the features must be on one scale.

Q · The model has more freedom than the data can constrain. How do you take some of it away without taking away the part that generalises, and how do you know how much to take?
Early Stopping
▶ lab

Stop training when validation loss stops improving, keep the best checkpoint, and accept that the validation set you stopped on is no longer an unbiased estimate of anything.

Q · Training loss is still falling. When do you stop, what do you keep, and what has the validation set become once it has decided that?