Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 1 of 13 in this unit

Understand Neural Networks · SOURCE LESSON 08

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.

Start with the exampleJump to the experimentRead the explanation
Prerequisites and path options

Why learn this? Avoid choosing a model that memorizes examples but fails on new ones.

01 · TRY

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 model
02 · PREDICT
Before you experiment

Which model would you trust more before a final test?

Which model would you trust more before a final test?
03 · EXPERIMENT

Change one thing. Watch what follows.

Loading this browser experiment…

04 · UNDERSTAND
READ & CONNECT

Understand what changed.

Back to the experiment

A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.

Same learning goal in both modes: Use validation data to choose a model, then freeze it before inspecting a separate test set.

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.

mean squared error=1n∑i=1n(y^i−yi)2\text{mean squared error}=\frac{1}{n}\sum_{i=1}^{n}(\hat y_i-y_i)^2

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.

05 · APPLY
Check your understanding

A student checks the final test score after every change and chooses the best model. What is the problem?

A student checks the final test score after every change and chooses the best model. What is the problem?
06 · CONTINUE

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.

My Learning
Explore related topics and the topic map

How this topic connects

Explore this topic on the interactive map

Use 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.

You are hereLearn the pattern, not the examples

A model can fit every training point and still fail on the next one. Find out how to tell.

What it enables

Show 11 more connections