MoonSay /Tutorials/Machine Learning Interview #2
Contents
  1. 01Introduction
  2. 02Setting and notation
  3. 03Intuition
  4. 04The decomposition and its proof
  5. 05A warm-up you can do by hand
  6. 06The experiment
  7. 07Models where every term has a formula
  8. 08Diagnosing bias and variance in practice
  9. 09Fixing high bias and high variance
  10. 10Beyond the classical picture
  11. 11Interview questions and model answers
  12. 12Summary
  13. 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 networkMore training data, or data augmentation
More or better featuresStronger regularization (larger \lambda; L1 or L2)
Weaker regularization (smaller \lambda)Simpler model, fewer features (feature selection)
Boosting: add weak learners sequentiallyBagging and random forests
Train longer, if optimization stopped too earlyEarly stopping, dropout (neural networks)
Smaller k in k-NN; deeper treesLarger k in k-NN; shallower or pruned trees
Table 3. Remedies. Many hyperparameters are bias–variance knobs: \lambda, k, tree depth, number of boosting rounds.

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(\frac1B\sum_{b=1}^B\hat f_b\Big)=\rho\,\sigma_f^2+\frac{1-\rho}{B}\,\sigma_f^2 .

\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.

Bagging fully grown regression trees (n=50, \sigma^2=0.09, 300 training sets): variance falls toward the floor \rho\sigma_f^2 predicted by Proposition 2, while bias^2 stays near zero. Data: computed for this tutorial.
Figure 10. Bagging fully grown regression trees (n=50, \sigma^2=0.09, 300 training sets): variance falls toward the floor \rho\sigma_f^2 predicted by Proposition 2, while bias^2 stays near zero. Data: computed for this tutorial.

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.