Bring the mental model from Linear Regression & Least Squares; this page will reuse it instead of restarting from zero.
Machine Learning
Bias-Variance Decomposition
Bias-variance decomposition separates generalization error into target mismatch, training-set instability, and irreducible noise.
Concept Structure
Bias-Variance Decomposition
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learning map
Bias-Variance DecompositionConceptual Bridge
What should feel connected as you move through this page.
Bias-variance decomposition separates generalization error into target mismatch, training-set instability, and irreducible noise.
The next edge should feel earned: use the demo prediction here before following Classification Metrics, Thresholds, and Calibration.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
You are here because "overfitting" is too vague by itself. A model can fail because it is systematically wrong, because it changes too much when the training data changes, or because the target is noisy even in the best possible world.
Before this, know least-squares regression. By the end, you should be able to name the randomness source in the decomposition, predict when a model is bias-dominated or variance-dominated, and run a small resampling witness.
Bias-variance is about imagined repeats of the training process. Hold one test input fixed. Now imagine drawing many different training sets from the same data-generating process, fitting a model on each one, and asking how the predictions at vary.
Three things can hurt expected squared error:
Bias is systematic miss. If the average fitted model is far from the true function, the model class is not flexible enough or the features are wrong.
Variance is training-set sensitivity. If different training sets produce very different predictions at the same , the model is flexible enough to chase sample noise.
Noise is irreducible target randomness. If the observed label is , no model can predict the fresh before it happens.
The common trap is to treat bias and variance as properties of one fitted curve. They are properties of the learning procedure under repeated samples.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Fix an input . Suppose the data-generating process is
where is the true conditional mean and has mean and variance . Let be the prediction made by a model trained on dataset . The randomness in comes from the draw of .
The expected squared prediction error at is
Add and subtract the average fitted prediction :
When has mean and is independent of the training-set draw, the cross terms vanish after expectation. The decomposition becomes
These are:
The decomposition is local to an input . A model can be low-bias in one region and high-bias elsewhere. Whole-dataset generalization error averages this picture over the input distribution.
The formula also assumes the fresh test noise has mean , has variance , and is independent of the training-set draw. If those assumptions change, the clean three-term story can pick up extra terms.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
rng = np.random.default_rng(7)
probe = 1.4
noise_sd = 0.25
def f_star(x):
return np.sin(1.4 * x)
def one_fit(degree, n=18):
x = rng.uniform(-3, 3, size=n)
y = f_star(x) + rng.normal(0, noise_sd, size=n)
coeff = np.polyfit(x, y, deg=degree)
return np.polyval(coeff, probe)
for degree in [1, 3, 9]:
preds = np.array([one_fit(degree) for _ in range(300)])
mean_pred = preds.mean()
bias2 = (mean_pred - f_star(probe)) ** 2
variance = preds.var()
expected_error = noise_sd ** 2 + bias2 + variance
print("degree", degree)
print(" bias^2:", round(bias2, 4))
print(" variance:", round(variance, 4))
print(" noise:", round(noise_sd ** 2, 4))
print(" total:", round(expected_error, 4))
The code mirrors the math: each call to one_fit draws a new training set , preds estimates the distribution of , and the mean of those predictions estimates $\bar f(x_0)`. These are Monte Carlo estimates, not exact values. High-degree raw polynomial fits can also add numerical conditioning artifacts; that is a separate problem from statistical variance.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Choose model flexibility, training-set size, noise, and a probe point. Before revealing the resampled fits, predict which term dominates the local error at the probe: bias, variance, noise, or a rough balance.
The reveal overlays many fitted curves from different training sets. If the average curve misses the true function at the probe, bias dominates. If the curves disagree with each other at the probe, variance dominates. If both are small relative to the noise slider, the remaining error is irreducible noise. The answer is local to the probe point and estimated from a finite set of resamples.
The noise readout is the variance , not the noise standard deviation. The fitted curves are a finite Monte Carlo witness, and the polynomial solver uses a tiny stabilizer so numerical blow-ups do not masquerade as statistical variance.
Live Concept Demo
Explore Bias-Variance Decomposition
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Bias-Variance Decomposition should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Bias-variance decomposition separates generalization error into target mismatch, training-set instability, and irreducible noise.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Bias-Variance Decomposition should make visible.
Visual Inquiry
Make the image answer a mathematical question
Bias-variance decomposition separates generalization error into target mismatch, training-set instability, and irreducible noise.
Which visible object should carry the first intuition?
Pick the cue that should make Bias-Variance Decomposition easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Claim source for expected test MSE at a fixed x0 and repeated-training-set bias-variance decomposition.
Open sourceCurriculum source for statistical-learning decomposition and resampling intuition.
Open sourceClaim Review
Bias-variance decomposition separates generalization error into target mismatch, training-set instability, and irreducible noise.
Claims without a substantive review badge still need exact source-support review.
isl-bias-variance, esl-bias-variance
Use equation, code, and demo objects to check whether the source support is operational.
ISLR directly supports the page's local fixed-x0 decomposition, repeated-training-set expectation, variance/bias terminology, irreducible-error term, and model-flexibility tradeoff framing.
Sources: An Introduction to Statistical LearningThis source check covers squared-error regression at a fixed input under the stated noise/training-draw assumptions; finite-resample demos are Monte Carlo estimates and raw high-degree polynomial fits can add numerical artifacts.A bounded review summary is present; still check caveats and exact source scope.Checked ISLR section 2.2.2: it states expected test MSE for a given x0 decomposes into variance of fhat(x0), squared bias, and Var(epsilon), and defines the expectation by repeatedly estimating f on many training sets and testing at x0. The page preserves fixed-input locality, training-set randomness, fresh-noise, Monte Carlo, and conditioning caveats.
Reviewer: codex+gpt-pro-prior; reviewed 2026-06-28Practice Loop
Try the idea before it explains itself
Bias-variance decomposition separates generalization error into target mismatch, training-set instability, and irreducible noise.
Before touching the demo, predict one visible change that should happen in Bias-Variance Decomposition.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
Bias-Variance Decomposition
What is the smallest example that makes Bias-Variance Decomposition click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:machine-learning/bias-variance-decomposition.
- Source ids to inspect: isl-bias-variance, esl-bias-variance
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Bias-Variance Decomposition Object key: concept:machine-learning/bias-variance-decomposition Context: Machine Learning Anchor id: concept/concept-notebook/machine-learning/bias-variance-decomposition Open question: What is the smallest example that makes Bias-Variance Decomposition click without losing the math? Evidence to inspect: - Source ids to inspect: isl-bias-variance, esl-bias-variance - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/machine-learning/bias-variance-decomposition
concept:machine-learning/bias-variance-decomposition