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
09Fixing high bias and high variance
| To reduce bias (add capacity) | To reduce variance (constrain or feed the model) |
|---|---|
| More flexible model: higher degree, deeper trees, larger network | More training data, or data augmentation |
| More or better features | Stronger regularization (larger \lambda; L1 or L2) |
| Weaker regularization (smaller \lambda) | Simpler model, fewer features (feature selection) |
| Boosting: add weak learners sequentially | Bagging and random forests |
| Train longer, if optimization stopped too early | Early stopping, dropout (neural networks) |
| Smaller k in k-NN; deeper trees | Larger k in k-NN; shallower or pruned trees |
9.1Regularization
Ridge (L2) shrinks coefficients, lasso (L1) sets some of them exactly to zero, and weight decay plays the role of L2 in neural networks. Section 7.3 showed how the penalty trades bias for variance; in Figure 8 it lowers the test error of the degree-12 polynomial from 0.791 to 0.146. Why L1 gives exact zeros and L2 does not, the diamond-and-circle geometry, the elastic net and how to choose \lambda are the subject of Episode 4 (the L1 vs L2 regularization tutorial).
9.2More data, and data augmentation
More data reduces variance without increasing bias, as (10) and Figure 6 showed. When real data are expensive, data augmentation, such as rotating or cropping images or adding noise to inputs, creates plausible new training examples and acts as a regularizer. More data does nothing for bias; if the learning curves have already met, the money is better spent on features or model capacity.
9.3Averaging: bagging and random forests
Bagging (Breiman, 1996) fits B models on bootstrap samples of the training set (samples of size n drawn with replacement) and averages their predictions. Its effect on variance follows from a short calculation.
Proposition 2. Let \hat f_1,\dots,\hat f_B be predictions at a point, each with variance \sigma_f^2, and with pairwise correlation \rho. Then (Hastie et al., 2009, eq. 15.1)
\Var\big(\sum_b\hat f_b\big)=\sum_b\Var(\hat f_b)+\sum_{b\neq b'}\Cov(\hat f_b,\hat f_{b'})=B\sigma_f^2+B(B-1)\rho\sigma_f^2. Dividing by B^2 gives \sigma_f^2/B+(1-1/B)\rho\sigma_f^2=\rho\sigma_f^2+(1-\rho)\sigma_f^2/B.
Averaging leaves the mean prediction, and therefore the bias, essentially unchanged, while the variance falls toward the floor \rho\sigma_f^2 as B grows. Figure 10 shows this for fully grown regression trees on the sine data with n=50 points: a single tree has squared bias 0.0005 and variance 0.095; averaging 100 bagged trees cuts the variance to 0.042 while the squared bias stays tiny (0.0002). The floor at about 0.042 corresponds to a correlation of roughly 0.44 between trees grown on different bootstrap samples of the same data. Random forests (Breiman, 2001) lower this floor further by decorrelating the trees: each split considers only a random subset of the features.
9.4Boosting
Boosting works on the other term. It starts from a deliberately simple, high-bias model, such as a shallow tree, and adds weak learners one at a time, each fitted to what the current ensemble still gets wrong. Each round reduces the remaining bias; the number of rounds and the learning rate control how far it goes before variance takes over, which is why boosting needs early stopping on validation data.
9.5Early stopping and other implicit regularizers
Training a neural network by gradient descent starts from small weights and moves gradually toward a fit of the training data. Stopping early, at the minimum of the validation error, keeps the weights small and acts much like an L2 penalty: fewer steps mean more bias and less variance (for a quadratic loss, stopping after \tau steps of size \eta is roughly an L2 penalty with \lambda\approx1/(2\eta\tau); see Episode 4). Dropout, which randomly removes units during training, can be read as training an implicit ensemble of thinned networks and so also reduces variance.