Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Prediction Error & Bias-Variance

Distinguish the error of one fitted model from the average performance of a learning procedure. Then separate prediction error into noise, bias, and variance.

Which Error Are We Measuring?

Let f^T=A(T)\widehat f_T=A(T) and let (X0,Y0)(X_0,Y_0) be an independent new pair.

QuantityDefinitionWhat is averaged?
Training errorerr⁡train(T)=n−1∑iL(Yi,f^T(Xi))\operatorname{err}_{\mathrm{train}}(T)=n^{-1}\sum_i L(Y_i,\widehat f_T(X_i))Losses on observations used to fit.
Conditional generalization errorErr⁡(T)=E[L(Y0,f^T(X0))∣T]\operatorname{Err}(T)=E[L(Y_0,\widehat f_T(X_0))\mid T]New inputs and outputs, keeping the fitted rule fixed.
Average generalization errorErr⁡n=ET[Err⁡(T)]\operatorname{Err}_n=E_T[\operatorname{Err}(T)]New observations and repeated training sets of size nn.

Model assessment estimates predictive performance. Model selection compares algorithms, model classes, or tuning choices. Reusing an assessment set for selection makes its reported error optimistic for the selected choice.

Train-Test Splitting

Split observations into disjoint training and test sets. Fit only on TtrainT_{\mathrm{train}} and compute

Err⁡^test=1ntest∑i∈testL(Yi,f^Ttrain(Xi)).\widehat{\operatorname{Err}}_{\mathrm{test}}= \frac{1}{n_{\mathrm{test}}}\sum_{i\in\mathrm{test}}L(Y_i,\widehat f_{T_{\mathrm{train}}}(X_i)).

For an independent, representative test set and a fitting procedure chosen without inspecting it,

E[Err⁡^test∣Ttrain]=Err⁡(Ttrain).E[\widehat{\operatorname{Err}}_{\mathrm{test}}\mid T_{\mathrm{train}}]=\operatorname{Err}(T_{\mathrm{train}}).

Increasing the test size improves precision for this fixed fitted model. The estimate does not directly assess a different model refitted on all the data.

Data rolePermitted use
TrainingEstimate coefficients and all learned preprocessing steps.
Validation or inner CVChoose the algorithm, features, and tuning parameters.
Final test or outer CVAssess the completed selection procedure.

A split spends data on both fitting and evaluation. With limited data, cross-validation reuses observations across different fitting/evaluation roles while keeping each scored prediction held out.

Why Training Error Can Mislead

An interpolating rule can satisfy f^T(Xi)=Yi\widehat f_T(X_i)=Y_i for every training observation, giving zero training error. Its behaviour between those points can still be poor. Zero residuals impose no general guarantee about loss at new inputs.

A training score is not always numerically below a realized test score. Optimism is an expectation statement under specified assumptions, not a pointwise inequality for every data split. The exact fixed-input version is developed on the next page.

Bias-Variance Decomposition

Bias: systematic error

Compare the average fitted prediction across training sets with the true regression function. Square that difference before adding it to prediction error.

Variance: sensitivity

Hold the input fixed and change the training set. Prediction variance measures how much the fitted prediction moves.

Write

Y0=m(x0)+ε0,E[ε0∣X0=x0]=0,Var⁡(ε0∣X0=x0)=σ2(x0).Y_0=m(x_0)+\varepsilon_0,\qquad E[\varepsilon_0\mid X_0=x_0]=0,\qquad \operatorname{Var}(\varepsilon_0\mid X_0=x_0)=\sigma^2(x_0).

The new error is independent of the training set. Define

f‾(x0)=ET[f^T(x0)],Bias⁡(x0)=f‾(x0)−m(x0).\overline f(x_0)=E_T[\widehat f_T(x_0)],\qquad \operatorname{Bias}(x_0)=\overline f(x_0)-m(x_0).

Then

ET,Y0∣x0[(Y0−f^T(x0))2]=σ2(x0)+Bias⁡(x0)2+Var⁡T(f^T(x0)).\boxed{ E_{T,Y_0\mid x_0}[(Y_0-\widehat f_T(x_0))^2] =\sigma^2(x_0)+\operatorname{Bias}(x_0)^2+ \operatorname{Var}_T(\widehat f_T(x_0)).}
ComponentInterpretationCan fitting reduce it?
Irreducible noiseDifferent responses at the same input.Not using these inputs alone.
Squared biasDistance between the average fitted prediction and the truth.A richer suitable model may help.
VarianceSensitivity of the prediction to the training sample.More data, averaging, or constraints may help.

Normality is unnecessary for this identity. Finite second moments and the independent new observation are the key requirements.

Derivation: Two Vanishing Cross Terms

First condition on TT and x0x_0:

E[(Y0−f^T(x0))2∣T,x0]=σ2(x0)+[m(x0)−f^T(x0)]2.E[(Y_0-\widehat f_T(x_0))^2\mid T,x_0] =\sigma^2(x_0)+[m(x_0)-\widehat f_T(x_0)]^2.

The noise cross term vanishes because E[ε0∣T,x0]=0E[\varepsilon_0\mid T,x_0]=0. Now write

m−f^T=(m−f‾)+(f‾−f^T).m-\widehat f_T=(m-\overline f)+(\overline f-\widehat f_T).

Average the square over training sets. The second cross term vanishes because ET[f‾−f^T]=0E_T[\overline f-\widehat f_T]=0. Thus

ET[(m−f^T)2]=(m−f‾)2+ET[(f^T−f‾)2].E_T[(m-\widehat f_T)^2]=(m-\overline f)^2+E_T[(\widehat f_T-\overline f)^2].

Adding noise gives the displayed decomposition. Averaging over X0X_0 yields the corresponding decomposition of Err⁡n\operatorname{Err}_n.

Complexity & Prediction

Increasing flexibility often reduces approximation bias but increases sensitivity to the training data. This motivates a balance; it does not prove that every algorithm has a U-shaped test-error curve or monotone bias and variance.

Training squared error cannot increase when least squares is minimized exactly over nested model classes. This fact alone says nothing about their ordering on new data.

Connection to classical regression: under the Gauss-Markov assumptions, least squares is best among linear unbiased coefficient estimators. That restricted variance comparison does not establish that it has the smallest prediction error among biased or nonlinear alternatives.