Learning from dataLesson 6 of 6
Where the error comes from
Expected prediction error, bias, and variance
The previous decomposition scored one fixed predictor. Now ask what happens if you repeat the entire training process with different data.
The fit is random too
Section titled “The fit is random too”Draw a training dataset and fit a model . Draw a different dataset from the same population and the fitted model usually changes. At one fixed input , those models give different predictions.
There are now two sources of randomness: which training dataset you got, and which future output you are asked to predict.
| experiment | keep fixed | vary |
|---|---|---|
| possible outputs at | the input | the fresh output |
| predictions at | the input and training method | the training dataset |
The second experiment defines the average prediction and the prediction variance . The subscript tells you what the averaging is over.
The same algebra, twice
Section titled “The same algebra, twice”Let . This is the population average prediction over hypothetical repeated training datasets—not the mean of the observed outputs.
At , define bias as that average prediction minus the true conditional mean:
For each fixed dataset, the earlier result gives expected error . Now average that expression over datasets. Apply the same variance identity to the random prediction :
We assume the new output is independent of the training data, conditional on the fixed input. Its zero-mean noise therefore contributes no cross term. If output variance depends on the input, replace with .
Bias asks whether the average prediction misses. Variance asks whether the fitted models disagree. Noise asks how much future outputs vary even at the same input.
Put numbers on the three parts
Section titled “Put numbers on the three parts”For a small toy experiment, suppose a training method produces each of the five listed predictions with equal probability. The true conditional mean is 4 and the output noise variance is 1.
| predictions | mean | bias | bias² | prediction variance | expected error |
|---|---|---|---|---|---|
| 7, 7, 8, 6, 7 | 7 | 3 | 9 | 0.4 | 10.4 |
| 4, 5, 4, 3, 4 | 4 | 0 | 0 | 0.4 | 1.4 |
| 1, 7, 4, 6, 2 | 4 | 0 | 0 | 5.2 | 6.2 |
For the last row, variance is . The average prediction is correct, but an individual fit can still miss badly.
For a real simulation with only five sampled fits, these numbers would be estimates of the theoretical quantities. More simulation runs can improve those estimates; that is different from adding more training examples to each fit.
Expected error is different from one test-set score
Section titled “Expected error is different from one test-set score”averages over training datasets and future outputs at a particular input. To obtain overall expected error, also average over inputs: .
A measured test MSE uses one fitted model and one finite test set. It is a noisy estimate of that fitted model’s performance. It is not exactly equal to the bias–variance decomposition across hypothetical datasets.
The tradeoff, and the five curves
Section titled “The tradeoff, and the five curves”In the classical example here, a rigid line cannot follow a curved relationship, while a high-degree polynomial can respond strongly to the noise in a small training set. This often produces decreasing bias, increasing prediction variance, and a U-shaped expected-error curve.
The decomposition is an identity under the stated conditions. Those particular curve shapes are a pattern, not a theorem about every learning method. Regularization, different model families, and sufficiently large models can produce different patterns. The advanced example called double descent is one reason to avoid treating the U as universal.
Rigid or flexible?
Section titled “Rigid or flexible?”These are starting hypotheses to check with validation data:
| situation | a reasonable starting point | reasoning |
|---|---|---|
| many observations, few features | allow more flexibility | more data can stabilize a flexible fit |
| many features, few observations | constrain or regularize the fit | otherwise many very different models may fit the same data |
| strongly nonlinear relationship | allow a suitable nonlinear shape | an inappropriate straight line can retain approximation error |
| large output noise | use stronger smoothing or regularization | small sample fluctuations are less reliable |
More data often reduces prediction variance. It does not make a straight-line model capable of representing every curved relationship. However, an estimator’s bias can also depend on sample size; “more data never changes bias” is too broad.
Practice and reference
Section titled “Practice and reference”Read an unfamiliar problem, review the cheat sheet, or try mixed practice.