The Bias-Variance Tradeoff Deep Dive

The bias-variance tradeoff is the central theoretical lens for understanding why models fail — either because they are too simple (high bias) or too sensitive to training data (high variance).


Decomposing Prediction Error

The expected prediction error for any model can be decomposed as: Error = Bias\u00b2 + Variance + Irreducible Noise. You can reduce bias or variance, but never both simultaneously without more or better data.

Bias: Systematic Error

Bias is the error from wrong assumptions in the learning algorithm. A high-bias model is too simple — it consistently misses the true pattern (e.g., fitting a straight line to clearly curved data). High bias leads to underfitting.

Variance: Sensitivity to Training Data

Variance is the error from excessive sensitivity to small fluctuations in training data. A high-variance model learns the noise in the training set and fails to generalise (e.g., a degree-15 polynomial on sparse data). High variance leads to overfitting.

The Tradeoff in Practice

As model complexity grows, bias decreases but variance increases. The optimal model sits at the sweet spot where total error is minimised.

Using Validation Curves

<pre><code class="language-python">from sklearn.model_selection import validation_curve from sklearn.linear_model import Ridge from sklearn.datasets import fetch_california_housing import numpy as np data = fetch_california_housing() alphas = np.logspace(-3, 3, 20) train_scores, val_scores = validation_curve( Ridge(), data.data, data.target, param_name="alpha", param_range=alphas, scoring="r2", cv=5 ) print("Mean train R\u00b2:", train_scores.mean(axis=1).round(3)) print("Mean val R\u00b2:", val_scores.mean(axis=1).round(3))</pre>