Statistics · medium

Explain the bias-variance tradeoff.

Asked in ML Engineer interviews, in the Statistics round.

Short answer

Bias = underfitting error; variance = overfitting error; minimize total generalization error.

How to answer it

A model's error on new data has two controllable parts. Bias is the error from the model being too simple to represent the pattern: it is wrong in the same way on every dataset. Variance is the error from the model being too sensitive to the particular training set: retrain on a different sample and it changes a lot. Plus irreducible noise you cannot do anything about.

Simple models have high bias and low variance; flexible models have low bias and high variance. As you add capacity, bias falls and variance rises, and total error is U-shaped. The goal is the bottom of the U, not either end.

How you see it in practice is the useful part:

from sklearn.model_selection import validation_curve
train_scores, val_scores = validation_curve(
    model, X, y, param_name="max_depth", param_range=range(1, 20), cv=5)
# the gap between train and val opening up is variance; both low is bias

Mention that modern deep networks complicate the classic curve (double descent), but the diagnostic, comparing training error with validation error, still works.

Related questions

Practice this for real