AI Grounds
Open AI Grounds on a desktop
These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.
AI Grounds
These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.
Guided discovery
Fit familiar points. Check predictions on held-out points.
Degree 1 is a straight line; higher degrees allow more flexible curves. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.
Scales each split’s own fixed deviations from the underlying signal. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.
Training circles determine the fit; held-out squares measure its predictions. The dashed curve is the underlying signal before noise.
Axes stay fixed across degrees for this scenario and noise: y -4.5 to 4.5. Changing scenario or noise can change this range. Plot lines join 120 evaluated x positions; exact predictions at every observed point appear below.
Average squared error on 12 points used for fitting.
≈ 0.20037
mean((observed y − predicted y)²)
Fits minimize training error plus a fixed tiny coefficient penalty.
Average squared error on 11 points withheld from fitting.
≈ 0.11187
Same error formula; different points.
Lower here means better predictions on this set.
Difference between the two finite-set errors.
≈ -0.08851
Held-out MSE − training MSE
Negative is possible; a positive gap alone is not proof of overfitting.
Every degree uses the same current points and fitting rule. Read both losses; degree and gap alone do not diagnose overfitting.
The loss scale stays fixed when degree changes. The chart summarizes these two finite sets; it does not guarantee an error on future data.
These fixed, illustrative splits use different noise patterns and are not an unbiased estimate of future error. In real work, choose complexity on validation data and reserve an untouched test set for final evaluation. Repeatedly choosing from test error leaks evaluation information.
| Degree | Training MSE | Held-out MSE |
|---|---|---|
| 1 (current) | 0.20037 | 0.11187 |
| 2 | 0.16500 | 0.06333 |
| 3 | 0.09565 | 0.00796 |
| 4 | 0.07891 | 0.00665 |
| 5 | 0.07590 | 0.00741 |
| 6 | 0.06199 | 0.01345 |
| 7 | 0.05747 | 0.02090 |
| 8 | 0.04843 | 0.04340 |
| 9 | 0.04454 | 0.03177 |
| 10 | 0.04300 | 0.07228 |
| 11 | 0.03048 | 0.18521 |
| 12 | 0.03039 | 0.17962 |
| Split / point | x | Observed y | Predicted y | Residual² |
|---|---|---|---|---|
| Training 1 | -0.96 | -0.47000 | -0.77866 | 0.09527 |
| Training 2 | -0.78 | -1.20847 | -0.65076 | 0.31105 |
| Training 3 | -0.62 | -0.76406 | -0.53706 | 0.05153 |
| Training 4 | -0.45 | -0.38803 | -0.41627 | 0.00080 |
| Training 5 | -0.27 | -0.77381 | -0.28836 | 0.23566 |
| Training 6 | -0.08 | 0.29556 | -0.15335 | 0.20152 |
| Training 7 | 0.11 | 0.19366 | -0.01835 | 0.04495 |
| Training 8 | 0.31 | 1.05637 | 0.12377 | 0.86974 |
| Training 9 | 0.5 | 0.35687 | 0.25878 | 0.00962 |
| Training 10 | 0.68 | 0.62434 | 0.38668 | 0.05648 |
| Training 11 | 0.84 | -0.12385 | 0.50037 | 0.38966 |
| Training 12 | 0.97 | 0.22097 | 0.59275 | 0.13822 |
| Held-out 1 | -0.88 | -0.91609 | -0.72181 | 0.03774 |
| Held-out 2 | -0.7 | -0.86298 | -0.59391 | 0.07240 |
| Held-out 3 | -0.54 | -0.85616 | -0.48022 | 0.14133 |
| Held-out 4 | -0.36 | -0.52334 | -0.35232 | 0.02925 |
| Held-out 5 | -0.18 | -0.20486 | -0.22441 | 0.00038 |
| Held-out 6 | 0.02 | 0.31486 | -0.08230 | 0.15773 |
| Held-out 7 | 0.22 | 0.52384 | 0.05982 | 0.21532 |
| Held-out 8 | 0.41 | 0.69688 | 0.19483 | 0.25206 |
| Held-out 9 | 0.59 | 0.54135 | 0.32273 | 0.04779 |
| Held-out 10 | 0.76 | 0.37409 | 0.44353 | 0.00482 |
| Held-out 11 | 0.91 | 0.02887 | 0.55011 | 0.27169 |
A degree d polynomial is a₀ + a₁x + … + a_d x^d. Only training points determine these coefficients. A fixed tiny penalty makes the fit unique even when coefficients outnumber training examples; its size does not jump with degree. The fitting objective is sum of squared training errors + 10⁻⁷ × (0.1a₀² + a₁² + … + a_d²). MSE displays the average squared prediction error alone, excluding that penalty. Numerical QR fitting avoids unstable normal equations.
The common illustrative signal is 0.58 sin(π(x + 0.12)) + 0.34x − 0.24x². Each preset keeps its original x positions and fixed train/held-out noise patterns. Noise zero removes deviations, but a finite polynomial need not match this signal exactly. The plotted signal is a teaching reference unavailable for real unknown data.
Balanced Split, degree 1, noise 0.34. Training MSE 0.20037; held-out MSE 0.11187; held-out minus train -0.08851. Only training points fit the curve.