Least Squares - Interactive Lab

Polynomial Curve Fitting Playground

Why does a model underperform? Often the shape of the hypothesis is wrong. A degree-1 line cannot bend, while a degree-3 cubic y = a0 + a1x + a2x2 + a3x3 can. Tap the canvas to add points, tune the degree, and watch train versus test error tell the story.

Degree-1 lineChosen degree fitTest points

Click or tap anywhere on the chart to add a data point. Every fourth point becomes a held-out test point.

Train RMSE (fit)-
Test RMSE (fit)-
Train RMSE (line)-
Test RMSE (line)-

Underfitting. Degree 1

A straight line has only two parameters: slope and intercept. If the true process curves, the line misses systematically. Train and test error are both high, and no amount of extra data fixes it. That is high bias, one of the most common reasons a model quietly underperforms.

Just right. Degree 3

The cubic y = a0 + a1x + a2x2 + a3x3 adds curvature and an inflection. On cubic-shaped data it hugs the trend without chasing noise, so train and test RMSE stay close. Matching model capacity to the structure of the data is the core lesson of curve fitting.

Overfitting. Degree 7+

Push the degree slider high and the curve starts threading through individual noisy points. Train RMSE plummets while test RMSE climbs. That gap between the two numbers in the panel above is the classic signature of overfitting: memorizing noise instead of learning signal.

Enjoy this tool? Build your own with Super