Lesson 1 of 13 in this unit
Learn the pattern, not the examples.
A model can fit every training point and still fail on the next one. Find out how to tell.
By the end: Use validation data to choose a model, then freeze it before inspecting a separate test set.
Prerequisites and path options
Why learn this? Avoid choosing a model that memorizes examples but fails on new ones.
Start with something concrete.
Imagine memorizing the answers to a practice exam. A perfect score on that sheet says little about tomorrow’s exam. Our lab fits curves through noisy points: more flexibility helps fit the sheet, but does it help on new points?
Try the interactive modelWhich model would you trust more before a final test?
Change one thing. Watch what follows.
Loading this browser experiment…
Understand what changed.
A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.
The idea in everyday terms
A model can fit familiar examples very closely and still predict new ones poorly. Training examples are used to adjust its parameters. Validation examples help choose settings, such as how flexible the curve should be. A final test checks the chosen model after those decisions are fixed.
What to watch in the experiment
Compare both error curves as you change complexity. A more flexible curve may follow noise in the training points. Lower training error alone cannot tell you whether that extra detail helps elsewhere. Freeze your choice before revealing the test result.
What this does not establish
This is a small synthetic experiment. Looking at the test and then tuning again makes it familiar development evidence; resetting the model cannot make that evidence unseen.
Open the full worked examples, calculations and limitations
This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.
Three datasets, three jobs
Training data fits the parameters. Validation data helps you choose settings such as model size or regularization. Test data estimates the final chosen model’s performance after those choices are frozen. Reusing the test score to make choices turns it into another validation score.
The lab uses 12 training points, 24 validation points, and 24 separately generated test points. All come from the same smooth toy relationship with independent noise. Circles are training observations; diamonds are validation observations. The curve is fitted only to the circles. The final test observations remain hidden until you freeze your choice.
A split must match the real task. If two almost identical photos of the same object land in different sets, the test may be too easy. For predicting the future, a time-based split can be more appropriate than shuffling everything. No split repairs unrepresentative or incorrectly labeled data by itself.
The most flexible curve is not always the best predictor
A polynomial adds powers of the input. Degree 1 is a straight line; a higher degree can bend more. In this lab, degree 11 has enough flexibility to pass through all 12 training points. Some of those points contain random noise, so a perfect fit can make the curve worse between them. This is overfitting. A model too restricted to capture the useful pattern underfits.
Compare degrees 1, 4, and 11. Training error falls as flexibility increases, but validation error does not keep falling. The comparison table reports actual measured errors from the fits; it is not an invented performance curve. Here, fitting solves a small least-squares system directly rather than running the gradient-descent animation from the previous module.
Every learning process has preferences
An inductive bias is a preference among explanations that could fit the observations. Model architecture, initialization, optimizer, regularization, and data all shape that preference. A model looking at neighboring pixels favors different patterns from one comparing words across a sentence.
Regularization adds a cost for certain parameter choices. Our lab penalizes the squared nonconstant polynomial coefficients. The fit therefore trades training error against that penalty. The displayed losses remain ordinary mean squared errors, without adding the penalty. This particular penalty depends on the numerical basis used to express the polynomial; it is one teaching choice, not a universal measure of simplicity.
More parameters do not automatically imply worse generalization. Modern networks can generalize even when they have enough parameters to memorize their data. Parameter count alone does not describe the solution actually found.
A good test has a boundary
Even an independent test only samples the conditions it contains. A model trained on bright photographs may fail in dim light. This is distribution shift: the conditions change. Test meaningful variations and report failures alongside successes.
Our frozen test is a small estimate, not proof of real-world reliability. If you reopen tuning after seeing it, it is no longer an unseen test. The lab keeps that warning even after a reset. In a real project, reserve new independent evidence for the next final claim.
A student checks the final test score after every change and chooses the best model. What is the problem?
Take this idea with you.
Fit with training data, choose with validation data, and evaluate the frozen choice on independent test data. A lower training error is not the same as better generalization.
Explore related topics and the topic map
How this topic connects
Explore this topic on the interactive mapUse these connections to review a foundation or choose where to go next. You can open any topic without completing the others.
What it builds on
- Loss and gradient descent
Recognize when training is improving or overshooting, so you can choose a useful step size instead of guessing.
- Averages
Combine outcomes with their frequencies or probabilities, keeping the denominator explicit when interpreting this lesson’s evidence.
A model can fit every training point and still fail on the next one. Find out how to tell.
What it enables
- Catch a model taking a shortcut
Catch models that rely on backgrounds or other accidental clues before those clues change in use.
- Teach useful invariances
Choose transformations that preserve a task’s answer and avoid augmentations that quietly change it.
- Compress and reconstruct
Inspect what a compressed representation keeps and loses before using it for another task.
Show 11 more connections
- Spend a limited compute budget
Compare model and hardware choices against a limited budget without confusing estimates with measured performance.
- Repair data without leaking answers
Repair a dataset without letting answers leak into training and make evaluation look better than it is.
- Recommend from incomplete feedback
Build recommendations without treating unobserved preferences as negative ratings.
- Validate without reusing the answers
Choose an evaluation split that reflects groups and time so the score answers the intended question.
- Choose complexity using development evidence
Choose regularization using recorded comparisons while keeping final evaluation separate from tuning.
- Explore before you decide
Understand why trying an uncertain option can improve later decisions, even when it costs something now.
- Learn from verified self-play
Evaluate learning from an opponent without mistaking repeated wins in practice for general skill.
- Build a trustworthy practice loop
Build practice loops that reward correct results instead of letting a weak checker reinforce mistakes.
- Learn a better way to adapt
Understand when learning a starting point can make later adaptation more efficient.
- Learn a shared representation contract
Diagnose why two models fail to communicate even when each works on its own.
- Learn from routing evidence without fooling yourself
Compare routing choices fairly when the available evidence depends on which options were tried.