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
Machine Learning Interview #2 · Tutorial

The Bias–Variance TradeoffUnderfitting vs Overfitting

Why a model that aces its training data can fail on new data, and what to do about it

A tutorial companion to the video Machine Learning Interview #2: The Bias–Variance Tradeoff PDF

01Introduction

1.1The question

“Explain the bias–variance tradeoff” is one of the most frequently asked questions in machine learning interviews, and for good reason: it is the conceptual core of almost every practical decision a modeller makes. How complex should the model be? Should I add features or remove them? Will more data help? How strongly should I regularize? Why does my model look perfect on the training data and disappointing in production?

All of these questions are about one gap. A model is fitted to a single training set, which is a random sample from some population, but it is evaluated on new data from the same population. Two very different things can go wrong. A model can be too rigid: it makes strong simplifying assumptions, misses real structure, and is wrong in the same way no matter which training set it sees. Or it can be too flexible: it bends to fit every quirk of the particular sample, including its noise, and so it changes a lot from one training set to the next. The first failure is called high bias, or underfitting; the second is high variance, or overfitting. The bias–variance decomposition makes this precise. Under squared loss, the expected prediction error splits exactly into three non-negative parts:

\text{expected test error} \;=\; \underbrace{\text{noise}}_{\text{irreducible}} \;+\; \text{bias}^2 \;+\; \text{variance}. \tag{1}

1.2A short history

Splitting the mean squared error of an estimator into squared bias plus variance is classical statistics, and the idea that a little bias can buy a large reduction in variance is old as well. Stein (1956) showed that, for estimating three or more normal means at once, the ordinary sample means can be beaten everywhere by an estimator that shrinks them toward a common point, a result made explicit by James and Stein (1961). Regularization methods that deliberately bias solutions to stabilize them were introduced for ill-posed problems by Tikhonov (1963) and for regression by Hoerl and Kennard (1970), who called it ridge regression. The decomposition entered machine learning through the influential paper of Stuart Geman, Elie Bienenstock and René Doursat, Neural Networks and the Bias/Variance Dilemma (Geman et al., 1992), which analysed neural networks and nonparametric estimators in exactly these terms. Ensemble methods followed: bagging (Breiman, 1996) and random forests (Breiman, 2001) reduce variance by averaging. Most recently, Belkin et al. (2019) showed that very large models can show “double descent”, a second drop in test error beyond the point where they fit the training data exactly (Section 10). Standard textbook treatments are Hastie et al. (2009, Section 7.3) and Bishop (2006, Section 3.2); lecture notes we found particularly clear include Ng and Ma (2023) and Weinberger (2018).