Home / Machine Learning

The Bias-Variance Tradeoff

By Updated

Explicitly control Bias and Variance to understand how models generalize. Use the Resample button to visualize the instability of High Variance models!

80%
10%
System Diagnosis

IDEAL BALANCE

Model accurately captures the trend without memorizing the noise.
Live Fit View
Train Data
Val Data
Model Prediction
True Function
Click "Resample Data" repeatedly to visualize Variance!

Training Error (MSE)

Error on the blue dots. High Error indicates High Bias (Underfitting). 0.000

Variance Gap

Difference between Val and Train. High Gap indicates High Variance (Overfitting). 0.000

Total Error (Val MSE)

Overall performance on unseen orange dots. The ultimate metric. 0.000

Overview

Bias describes systematic error from a model that is too restrictive; variance describes how much its predictions change across training samples. The distinction helps explain why a model can underfit or overfit, and why adding complexity is not always an improvement.

The two sources of model error

Imagine training the same kind of model on many different samples from one population. Bias is how far its average prediction is from the target pattern. Variance is how much those fitted predictions differ from one another. A rigid straight line trying to fit a curved relationship may have high bias. A very flexible curve that changes sharply whenever the sample changes may have high variance.

For squared-error regression, under the usual assumptions, expected prediction error can be written as:

Expected squared error = bias² + variance + irreducible noise

Irreducible noise is variation in the outcome that the available features cannot explain. This decomposition is not a universal formula for every model or metric; it is a way to reason about expected squared error.

Read the training and validation errors

PatternLikely diagnosisWhat to consider
Both errors are high and closeUnderfitting, often high biasAdd useful features or model flexibility; reduce excessive regularisation.
Training error is low but validation error is much higherOverfitting, often high varianceSimplify, regularise, gather representative data, or use cross-validation.
Both are low and closeThe model generalises well on this splitCheck whether the validation data represents deployment.

These patterns are clues, not proof. Data leakage, a distribution shift, a small validation set, or a mismatched metric can also create misleading curves. See learning curves for how error changes as training data grows.

Explore resampling

  1. Set Bias high and Variance low, then click Resample Data several times. The model should stay relatively stable while missing the underlying trend.
  2. Set Bias low and Variance high, then resample. A flexible model can fit the sample closely, but its prediction curve moves more between samples.

The visualiser is a teaching model, not a diagnostic estimator. In a real workflow, compare training and validation performance using the same split strategy and a metric suited to the task.

Why increasing complexity has a trade-off

More flexible models can represent a wider range of patterns, which may reduce bias. The same flexibility can also fit random quirks in the training data, increasing variance. Regularisation, model selection and additional representative data change this balance; none guarantees that both sources of error will fall at once.

Sources and next steps

Continue with learning curves to diagnose whether more data may help, and cross-validation to compare models across multiple splits.

Predict, then reveal

About to run: set Data Noise to its minimum (0.0). Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. What does this module say about “The two sources of model error”?

  2. What does this module say about “Read the training and validation errors”?

  3. What does this module say about “Explore resampling”?

Cheat sheet

Bias vs Variance

Dial bias and variance up and down, resample the data, and watch a stable underfit turn into an unstable overfit.

MACHINE LEARNING · vizlearn.in/machine_learning/bias_vs_variance.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.