Contents
- 01Introduction
- 02Setting and notation
- 03Intuition
- 04The decomposition and its proof
- 05A warm-up you can do by hand
- 06The experiment
- 07Models where every term has a formula
- 08Diagnosing bias and variance in practice
- 09Fixing high bias and high variance
- 10Beyond the classical picture
- 11Interview questions and model answers
- 12Summary
- References
08Diagnosing bias and variance in practice
On a real problem you have one training set and you never observe f, so you cannot compute \Bias^2 and \Var directly. You can, however, observe their symptoms by comparing errors on data the model was trained on with errors on data it was not.
8.1Training, validation and test data
The standard workflow holds out part of the data. The model is fitted on the training set; hyperparameters and model choices are compared on a validation set (or by k-fold cross-validation, which rotates the role of validation data through the whole sample); and a final, untouched test set estimates the performance of the chosen model. Validation error estimates the left-hand side of (6), the expected test error; training error, as Proposition 1 showed, underestimates it.
8.2Reading the two numbers
Pause and think. Model A has training error 0.50 and validation error 0.53. Model B has training error 0.01 and validation error 0.52. Which has high bias, and which has high variance?
Show the answer
A: both errors are high and close together, so the model is too simple to fit even its own training data: high bias. B: a tiny training error but a large gap to validation error: it fits its sample very well and does not transfer, which is high variance. (These are the degree-1 and degree-12 polynomials of Table 1.)
Table 2 summarizes the pattern. Note that the two failure modes are not mutually exclusive: a model can show a high training error and a large gap, in which case both terms need attention.
| High bias (underfitting) | High variance (overfitting) | |
|---|---|---|
| Training error | high | low |
| Validation error | high, close to training error | much higher than training error |
| Learning curves | converge quickly to a high plateau | large gap that shrinks slowly with more data |
| Typical cause | model too simple, too much regularization, missing features | model too flexible for the amount of data |
| Will more data help? | no | yes |
8.3Learning curves
A learning curve plots training and validation error against the size of the training set (Figure 9, computed for the two models of the quiz above). With high bias, the two curves meet quickly at an error well above the target: the model is too simple to use additional data, so more data will not help. With high variance, there is a large gap that closes slowly as n grows: the variance shrinks with more data, so collecting more data does help. Learning curves are cheap to produce, since you only refit on subsets of the training data, and they answer the most expensive question in practice: whether to invest in more data or in a better model.
A validation curve plots training and validation error against a complexity hyperparameter, such as the polynomial degree (Figure 5) or the ridge penalty (Figure 8). It is the practical version of the U-shaped curve: choose the hyperparameter at the minimum of the validation error, or, following the “one-standard-error rule” (Hastie et al., 2009, Section 7.10), the simplest model whose validation error is within one standard error of that minimum.
8.4Four diagnostic scenarios
- Training error 30%, validation error 31%, target 5%. High bias. Add capacity or better features; reduce regularization. More data will not help.
- Training error 1%, validation error 12%. High variance. Regularize, simplify, ensemble, or collect more data; check the learning curve to see whether more data is worth it.
- Training error 15%, validation error 30%. Both. Usually address variance first if the gap is large, then revisit capacity, or change the model family altogether.
- Training error 4%, validation error 5%, target 5%. Done, provided the validation set resembles the production data. If production data differ (Section 3, the Literary Digest), validation error is itself biased.