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

03Intuition: many ways to see bias and variance

Before any algebra, it helps to see the same two ideas in several familiar settings. In every example below, ask two questions: where does the method land on average, and how much does it move around when the circumstances that should not matter change?

3.1The dartboard

The most widely used picture (Domingos, 2012) treats each trained model as a dart thrown at a target whose bullseye is the true value f(x) (Figure 1). Each dart corresponds to a model trained on a different random training set. Bias is how far the centre of the cloud of darts is from the bullseye; variance is how widely the darts are scattered around their own centre. A good procedure throws darts that are both centred and tight. The two failures are independent of each other: a procedure can be biased but consistent (top right), unbiased but erratic (bottom left), or both (bottom right).

The dartboard analogy. Each dot is one model trained on a different random training set; the gold bullseye is the true value, the purple cross the average of the models and the dashed orange circle their spread. Illustration drawn for this tutorial; the analogy follows Domingos (2012).
Figure 1. The dartboard analogy. Each dot is one model trained on a different random training set; the gold bullseye is the true value, the purple cross the average of the models and the dashed orange circle their spread. Illustration drawn for this tutorial; the analogy follows Domingos (2012).
Try itMove the aim, change the spread

Each teal dot is one model trained on a different training set. Bias moves where the models aim on average (purple cross); spread controls how much they disagree (dashed circle). For any set of darts the mean squared distance to the bullseye splits exactly into the two parts shown on the right.

3.2Accuracy and precision of a measuring instrument

Measurement science uses exactly the same two ideas under different names. The international standard ISO 5725-1 and the International Vocabulary of Metrology describe the accuracy of a measurement method in terms of trueness, the closeness of the average of infinitely many replicate measurements to a reference value, and precision, the closeness of repeated measurements to each other, usually expressed as a standard deviation (International Organization for Standardization, 2023; Joint Committee for Guides in Metrology, 2012). The vocabulary defines measurement bias as an estimate of the systematic error, which is exactly the \fbar(x)-f(x) of Definition 1; precision is the counterpart of variance. Think of two bathroom scales. The first always reads about two kilograms too high but gives the same reading every time you step on it: excellent precision, poor trueness, which is high bias and low variance. The second is correct on average but its readings jump by several kilograms between attempts: good trueness, poor precision, which is low bias and high variance.

The analogy teaches a lesson that carries over directly to machine learning. Stepping on the erratic scale ten times and averaging the readings reduces its variance by a factor of ten, because \Var(\bar z)=\sigma^2/10 for independent readings. But averaging can never remove the first scale’s two-kilogram offset. Repetition fixes variance, not bias. This is exactly why averaging many models (bagging, Section 9.3) reduces variance but leaves bias essentially unchanged.

The same split applies to human judgment. Kahneman et al. (2021) call the variance part noise: unwanted variability among judgments that should agree, such as two insurance underwriters quoting different premiums for the same policy, or two judges handing down different sentences for similar cases. For a set of judgments of the same quantity, the mean squared error equals bias^2 plus noise^2, and the authors argue that organizations routinely audit the first while ignoring the second, although it is often just as large.

3.3A famous biased sample: the 1936 Literary Digest poll

In 1936 the magazine Literary Digest mailed about ten million ballots and received roughly 2.4 million replies, one of the largest polls ever taken. It predicted a comfortable victory for Alf Landon over Franklin D. Roosevelt; Roosevelt won in a landslide with about 61% of the vote. Analyses of the failure point to the sample, not its size: the mailing lists over-represented wealthier voters, and those who chose to reply differed from those who did not. Using a survey taken shortly after the election, Squire (1988) concluded that both the sampling frame and the non-response were biased.

The bias–variance lens shows why size could not help. With n\approx 2.4 million responses, the sampling standard error of an estimated proportion near 0.57 is

\sqrt{\frac{0.57\times0.43}{2.38\times10^{6}}}\approx 0.00032,

about 0.03 percentage points, so a 95% sampling interval is only about \pm0.06 points wide. The poll’s actual error was close to twenty points. Essentially all of it was bias. The variance was negligible, and no amount of additional mail from the same lists would have reduced the bias. Machine learning has the same lesson: more data from the wrong distribution, or a model family that cannot represent the truth, does not fix systematic error.

Meng (2018) made this precise. For an estimate of a population mean computed from a non-random subset of n out of N people, the error equals the product of three factors: the correlation between being included and the value being measured (the “data defect”), the factor \sqrt{(N-n)/n}, and the population standard deviation. Because the first factor does not shrink as n grows, a huge self-selected sample can be worth very little. In his analysis of the 2016 US presidential election, a data-defect correlation of only about -0.005 made roughly 2.3 million self-reported responses about as informative as a simple random sample of about 400 people.

Modern polls are not immune either. Across 4,221 polls of US elections, Shirani-Mehr et al. (2018) found an average error of about 3.5 percentage points, roughly twice what the reported margins of error imply, and about 2 points of it was bias shared by all polls of the same election. Shared bias is the reason averaging many polls helps less than one might hope: averaging removes the independent part of the errors but not the common part, exactly the floor \rho\sigma_f^2 we will meet in bagging (Proposition 2).

3.4Two students preparing for an exam

Imagine two students preparing for an exam from a book of past papers. The first memorizes every past answer word for word: perfect on the practice papers, lost on the real exam, whose questions are new. Had they studied a different set of past papers, their “model” would have been completely different. This is high variance. The second learns a single rule of thumb and applies it everywhere: their score barely depends on which papers they studied, but it is mediocre throughout, because the rule is too simple for the subject. This is high bias. A good student learns the underlying principles, flexible enough to capture the real structure but not so flexible that they memorize accidents of the sample.

3.5Examples from applied machine learning

Predicting house prices. A linear regression on floor area alone is stable (it barely changes when a few sales are added or removed) but systematically wrong for houses whose price depends on location, age and condition: high bias. A 1-nearest-neighbor model on thirty features copies the price of the single most similar past sale, quirks and all: retrain it on last month’s sales instead of this month’s and its predictions change a lot. That is high variance. Gradient-boosted trees or a regularized linear model on well-engineered features usually sit in between.

Rating items with few votes. Online platforms that rank products, films or restaurants face a classic version of the tradeoff. An item with three five-star ratings has a perfect average, but that average is extremely noisy. A common remedy is a “Bayesian average” that shrinks each item’s mean rating toward the global mean, more strongly when the item has few votes. Shrinking introduces a small bias toward the global mean and removes a large amount of variance; Section 5 works out exactly when this pays off.

Portfolio choice. Mean–variance portfolio optimization picks asset weights from estimated expected returns and covariances. With realistic amounts of history these estimates are so noisy that the “optimal” weights mostly fit estimation error. DeMiguel et al. (2009) compared fourteen optimized rules with the naive rule that splits money equally among N assets; none of them consistently beat it out of sample, and they estimated that for 25 assets the optimized rule would need about 3,000 months of data to do so reliably. The naive rule is heavily biased (it ignores all the data) but has zero estimation variance.

Google Flu Trends. Google Flu Trends estimated influenza activity from search queries. Its initial model was selected by matching some 50 million search terms against 1,152 weekly data points, a recipe for fitting noise: some selected terms tracked winter rather than flu (variance). Later versions systematically overestimated flu prevalence, in 100 of 108 weeks from August 2011 (bias) (Lazer et al., 2014).

3.6Bias can be a feature: heuristics in human cognition

Bias is not always a defect to be eliminated. Psychologists studying human decision making have argued that simple heuristics, which ignore much of the available information, often predict better than complex strategies when experience is limited, precisely because they have low variance (Gigerenzer and Brighton, 2009). One of their illustrations uses daily temperatures in London in the year 2000: polynomials fitted to random samples of 30 days fit the sample better and better as the degree grows, but predict new days best at degree 4, and worse beyond it, the same U-shape as Figure 5. They also note that “bias” here is the statistical term, not the cognitive biases of popular psychology. Domingos (2012) draws the same lesson for machine learning: a naive Bayes classifier can beat a rule learner on small samples even when the truth is a set of rules, because, in his words, “strong false assumptions can be better than weak true ones.” A small amount of bias is the price of robustness. The same insight underlies regularization, pruning and early stopping in machine learning: when data are scarce, a deliberately constrained model is usually the better bet.

Pause and think. A colleague’s model has training error close to zero. Is that evidence of a good model, of a model with high bias, or neither?

Show the answer

Neither, by itself. Near-zero training error rules out high bias on the training data, but says nothing about variance; a model that memorizes its sample has near-zero training error and can still fail on new data. You need held-out data to tell (Section 8).