Bias-Variance Tradeoff (Underfitting vs Overfitting)
Context: FIT1043_MOC, FIT2086_MOC · how model complexity governs fit quality · why a polynomial’s degree and a regression’s predictor set are the same decision · measured on a held-out test set or scored by an information criterion · lab: 30_Projects/FIT1043_Labs/Week6-BiasVariance-Solution.pdf
Quick Revision
- 🎯 Objective: balance model complexity ➔ too simple underfits (high bias), too complex overfits (high variance).
- 📦 Core Components: bias = distance from the true function | variance = how much predictions swing across datasets.
- ⚡ Key Constraint: you can’t minimise both at once — reducing bias (more complexity) raises variance; the sweet spot is the tradeoff, and in-sample fit cannot find it.
📝 How It Works
1. Underfitting vs Overfitting
- Underfitting ➔ the model is too simple to capture the underlying structure (a straight line for a curve); poor fit due to high bias.
- Overfitting ➔ the model is too complex for the data (many parameters, little data) ➔ it fits the noise and makes wild predictions (a 25th-degree polynomial contorts wildly).
- Complexity ➔ more parameters ⇒ a more flexible curve; with little data this flexibility becomes overfitting.
2. Bias and Variance
- Model family & hyperparameter ➔ a family is a class of models set by a hyperparameter (here the polynomial order); giving the coefficients instantiates one member.
- Bias ➔ how close a family member can fit the true function; simple/low-order ⇒ large bias ⇒ underfitting.
- Variance ➔ the mean squared error between the fitted curves and the best-possible fit (same algorithm on “infinite” data) — how much fits swing across different datasets; complex/high-order ⇒ small bias but large variance ⇒ overfitting.
- Key nuance ➔ variance measures difference between fits, not difference from the truth; a high-order fit tracks truth well but occasionally “goes wild”, giving large variance overall.
3. Train / Test Split
- Split ➔ divide data into non-overlapping training and test sets.
- Rule ➔ build the model on training; evaluate on test; never evaluate on the training set (it hides overfitting).
4. Complexity as a Predictor-Set Choice (FIT2086 W6)
- Same tradeoff, regression vocabulary ➔ underfitting = omitting important predictors ➔ systematic error, bias in predicting the target; overfitting = including spurious predictors ➔ the model learns noise and random variation.
- Generalisation ➔ the named goal: performance on new, unseen data from the population, not on the sample fitted.
- Degree selection is predictor selection ➔ fitting makes “how many terms?” identical to “which predictors?” — on the lecture’s 50-sample dataset underfits, overfits, and is “just right” (the true relationship is fifth-order — W8).
- How the sweet spot is actually found ➔ not by eye and not by in-sample fit ➔ a penalised score (Model Selection and Information Criteria (AIC, BIC)) or held-out evaluation (Plug-in Prediction and Held-Out Evaluation).
- Which criterion leans which way ➔ AIC is more likely to overfit (keeps spurious predictors), BIC more likely to underfit (drops real ones) — the bias–variance dial, expressed as a penalty size.
5. The Formal Decomposition (FIT2086 W8)
- Population model ➔ ; for regression , , .
- Fit depends on the sample ➔ training sample gives ; a new from the same population gives a different fit ➔ this repeated-sampling variation defines bias and variance.
- Bias at ➔ — average fitted value minus true value ➔ systematic error: are the fits centred on the truth?
- Variance at ➔ ➔ how much the fitted value moves across training samples.
- Estimation error ➔
averaged over a grid of ⟹ .
- Prediction error ➔ a new observation adds noise the model can never remove:
➔ is the irreducible error: model selection trades bias against variance but cannot touch it.
- Sample size ➔ variance generally falls as grows; approximation bias from a too-simple model does not disappear with more data.
- Mapping ➔ underfitting ⟹ high bias, low variance (MSE driven by bias); overfitting ⟹ low bias, high variance (extra flexibility chases the noise; e.g. fitted coefficients are non-zero even though the true ones are ).
- Subtleties ➔ including every associated predictor may not remove bias if the relationship needs a transformation · you can underfit and overfit at once (omit an important predictor, include an unnecessary one) · omitting a weak predictor can improve prediction when estimating its coefficient adds more variance than the bias it removes · combine statistical tools with real-world knowledge.
6. Simulation Evidence (FIT2086 W8)
- Setup ➔ truth ; each training sample: , , , ; samples; each fit evaluated on a -point grid in ➔ average fitted value, variance, squared bias per , then averaged over the grid (plus 2.5/97.5 percentile bands).
| Fitted order | variance | Verdict | ||
|---|---|---|---|---|
| 2 | underfit — poor average fit, tight band | |||
| 7 | good average fit, wider band | |||
| 20 | overfit — widest band, worst near the boundaries |
⚖️ Core Decision Matrix
| Complexity | Bias | Variance | Fit | Regression reading |
|---|---|---|---|---|
| too low (e.g. linear on a curve) | high | low | underfit | important predictors omitted |
| balanced | moderate | moderate | good | the criterion-selected subset |
| too high (e.g. 25th-degree) | low | high | overfit | spurious predictors included |
When It Flips: the truth's shape decides the winner — for a near-straight truth a linear model beats a 3rd-order (lower variance, similar bias); for a curved truth linear underfits (high MSE) and higher-order polynomials win. There is no single best complexity (No Free Lunch Theorem).
📊 Exam Execution Trace & Applied Exercises
Applied Exercise — diagnose from training vs held-out error (W12 revision)
Problem: (i) polynomial fits with training/CV MSE: degree · degree · degree . (ii) training/test accuracy: logistic regression · decision tree · random forest . Which under/overfits, and which do you keep?
- Underfit ➔ high error on both sets: degree .
- Overfit ➔ low training, high held-out error — the gap is the signal: degree ( vs ) · decision tree (, the largest gap).
- Keep ➔ smallest held-out error: degree (CV MSE ) · random forest (test ) — averaging many randomised trees cuts the single tree’s variance (Random Forest).
Final Extracted Output: training error is optimistic and keeps falling as complexity rises ⟹ select on CV / test error, never on training error (Cross-Validation).
⚠️ Common Mistakes
- 💡 Evaluating on training data hides overfitting ➔ an overfit model scores great on train, poorly on test; always judge on the held-out test set or a penalised score.
- 💡 Overfitting wastes a close fit ➔ if the data has known noise, chasing every point fits the noise, not the signal.
- 💡 Expecting more data to cure underfitting ➔ extra shrinks variance only; a quadratic can never represent a fifth-order truth.
- 💡 Promising to remove all error ➔ is irreducible; only responds to model choice.
- 💡 Reading “more predictors improved ” as progress ➔ that improvement is guaranteed and says nothing about generalisation.
🧠 Active Recall
Define bias and variance, and link each to underfitting or overfitting.
- Hint: Accuracy vs stability.
Answer
- Short answer: Bias = distance of predictions from the true function (high bias ⇒ underfitting, inaccurate); variance = spread of predictions across datasets (high variance ⇒ overfitting, unstable).
- Why: Complexity dial ➔ raising complexity lowers bias but raises variance; the tradeoff picks the balance that minimises test error.
Why must you evaluate on a separate test set, not the training set?
- Hint: Generalisation.
Answer
- Short answer: A model can memorise the training data (overfit) and score well on it while failing on new data; the held-out test set measures genuine generalisation.
- Why: Non-overlapping split ➔ test points were never seen in fitting, so test error reflects real predictive quality.
Express the bias–variance tradeoff purely in terms of which predictors a regression includes.
Answer
- Short answer: Dropping a genuine predictor underfits and injects bias; adding a spurious one overfits and injects variance by letting the model chase noise.
- Why: The penalty is the dial ➔ AIC’s mild charge errs toward including too many, BIC’s charge errs toward too few ➔ Model Selection and Information Criteria (AIC, BIC).
At a fixed , refitted models give values that are tightly clustered but whose average is far from . Is the error mainly bias or variance?
Answer
- Short answer: Primarily bias — the tight cluster means small variance, the offset average means large systematic error.
- Why: Decomposition ➔ is large while is small ➔ the signature of underfitting.