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

10Beyond the classical picture

10.1Double descent

Modern neural networks often have far more parameters than training examples and can fit their training data exactly, yet they generalize well. Belkin et al. (2019) showed that, as capacity grows past the interpolation threshold, where the model can just fit the training set exactly, test error can peak and then fall again (Figure 11); they observed this for random-feature models, neural networks and ensembles of trees. Nakkiran et al. (2020) found the same “deep double descent” in modern deep networks, as a function of model size, training time and even sample size.

Double descent in our running example. We can reproduce the phenomenon with the polynomial experiment of Section 6. Keep the same truth, noise and n=15 points, and fit least squares with p Legendre polynomial coefficients (a polynomial of degree p-1; the k-th basis function is scaled by 1/k, which makes high-degree wiggles “expensive”). When p>n the equations have infinitely many exact solutions, and we take the one with the smallest norm. This is not an arbitrary choice: it is the solution that gradient descent started from zero converges to. Figure 11 shows the result over 500 training sets.

  • For p<n we see the classical U: the test error is smallest at p=6 (degree 5, as in Table 1), at 0.123.
  • As p approaches the interpolation threshold p=n=15, the variance explodes and the test error reaches about 100. With exactly as many coefficients as points there is a single interpolating polynomial, and it must bend violently to pass through every noisy label. The variance blow-up of degree 12 in Table 1 is the beginning of this peak.
  • Past the threshold the test error falls again, to 0.217 at p=20 and 0.168 at p=400, because among the many interpolants the minimum-norm one is smooth. In this small example the second descent does not beat the classical optimum; in the experiments of Belkin et al. (2019) it sometimes does.
Double descent on the running example: minimum-norm least squares with p (scaled) Legendre coefficients on n=15 points, 500 training sets per p, log scales. Variance peaks at the interpolation threshold p=n; beyond it, test error decreases again. Data: computed for this tutorial; the phenomenon was described by Belkin et al. (2019).
Figure 11. Double descent on the running example: minimum-norm least squares with p (scaled) Legendre coefficients on n=15 points, 500 training sets per p, log scales. Variance peaks at the interpolation threshold p=n; beyond it, test error decreases again. Data: computed for this tutorial; the phenomenon was described by Belkin et al. (2019).

What is going on. The decomposition (5) still holds in this regime; what changes is how the terms behave. First, the peak is a property of an unregularized algorithm at one particular size: with a well-tuned ridge penalty, the test error of least squares decreases smoothly as p grows and the peak disappears (Hastie et al., 2022; Ng and Ma, 2023). Second, parameter count is a poor measure of complexity. Among the many functions that interpolate the training data, the training algorithm tends to find low-norm solutions, and adding capacity gives it more room to find smooth ones; measured by the norm of the solution rather than by p, the curve looks classical again (Ng and Ma, 2023). Third, studies that measured bias and variance directly in neural networks found that variance need not grow with width. Neal et al. (2018) reported variance decreasing with network width. They also split the variance into a part due to sampling the training data and a part due to random initialization and optimization, and found that the second part vanishes as networks get wider. Yang et al. (2020) found that bias typically decreases with width while variance first rises and then falls. Depending on which term dominates, the test error is then monotonically decreasing, double-descent shaped, or bell shaped.

10.2Classification and zero–one loss

Theorem 1 is specific to squared loss. For classification with zero–one loss, L(y,\hat y)=\mathbf{1}[y\neq\hat y], the expected error does not split additively into bias and variance, and several alternative definitions exist (Kohavi and Wolpert, 1996; Domingos, 2000). In the framework of Domingos (2000), the main prediction y_m(x) is the most common prediction across training sets; the bias is whether y_m(x) differs from the optimal (Bayes) prediction; and the variance is the probability that a single model’s prediction differs from y_m(x). For two classes, variance adds to the error at points where the main prediction is correct but subtracts from it where the main prediction is wrong: if the procedure is usually wrong at a point, a model that sometimes disagrees with it is sometimes right. This is one reason why averaging, which reduces variance, helps less predictably for classification than for regression. For probabilistic classifiers evaluated with squared error on the predicted probabilities (the Brier score), Theorem 1 applies unchanged.

10.3Common misconceptions

The tutorials and papers cited here warn against a handful of recurring mistakes (Neal, 2019; Ng and Ma, 2023; Weinberger, 2018).

  1. “A decomposition implies a tradeoff.” Theorem 1 is an identity. Whether lowering one term raises the other depends on the knob being turned; more data or better features can lower both (Neal, 2019).
  2. “Complexity means number of parameters.” What matters is how much the fitted function can change with the data. k-NN has no fitted parameters at all, yet with k=1 it follows every training point (each point owns its own cell of the input space) and is the most flexible setting of k; its effective number of parameters grows with the size of the data set (Murphy, 2022, §16.1). In the other direction, ridge regression keeps all p coefficients, but its effective degrees of freedom \mathrm{df}(\lambda)=\sum_jd_j^2/(d_j^2+\lambda) fall from p towards 0 as \lambda grows (Murphy, 2022, §11.3.2): in the polynomial experiment of Section 7.4 the same 13 coefficients use 13, 9.4 or 2.9 effective degrees of freedom, depending on \lambda.
  3. “More data fixes everything.” More data reduces variance only (Figure 6). It does not touch bias (the Literary Digest), and near the interpolation threshold more data can even make an unregularized model worse (Nakkiran et al., 2020).
  4. “An unbiased model is always preferable.” We only ever get one training set. An unbiased procedure with high variance gives an unbiased answer on average over many training sets, and a bad answer on the one we have (Sections 5 and 7.3).
  5. “Variance comes only from the data.” Random initialization, random mini-batches and random feature subsets also make the fitted model random, and contribute to its variance (Neal et al., 2018).
  6. “A model that fits well predicts well.” A good fit to the training data is evidence about bias, not about variance (Proposition 1 and Figure 5).