Concepts 🚀 Project 🧮 Labs
🧮 Labs / ML Advanced / Interactive: Overfitting — drag polynomial degree + see train vs test

Interactive: Overfitting — drag polynomial degree + see train vs test

DRAG the polynomial degree slider. SEE the curve go from straight line (underfit) to wiggly mess (overfit). SEE train vs test error diverge.

interactive.lab v3.1
Drag the sliders — see the graph update in real-time
Live interactive chart drag sliders → graph updates
If you see this, the interactive chart is loading...
If it doesn't appear in 2 seconds, press Ctrl+Shift+R to hard refresh.
🧠 How it works

INTERACTIVE OVERFITTING: This is the #1 reason ML models fail in production. DRAG the degree slider from 1 to 15 and WATCH: Degree 1: model is a straight line. Can't capture the sin curve. Train error HIGH, test error HIGH. → UNDERFITTING. Degree 3-5: model captures the curve. Train error LOW, test error LOW. → GOOD FIT. Degree 15: model passes through every training point perfectly! Train error = 0. But test error EXPLODES. → OVERFITTING. The GAP between train and test error is the overfitting signal. If train >> test, your model is memorizing, not learning. FIXES: (1) reduce degree, (2) more data, (3) regularization, (4) cross-validation.

✏️ Try these changes
  • Set degree=1 — straight line
    → can't capture the curve — underfitting
  • Set degree=15 — wiggly mess
    → passes through every training point, fails on test — overfitting
  • Set noise=0.4 — very noisy data
    → harder to find the right degree
  • Set degree=4 — good fit
    → captures the sin pattern without overfitting