RegressionSample

Polynomial regression

Adds powers of the input so a linear model can fit curves.

Synthetic data, generated and trained in your browser.

Try this

  1. 01Set degree 1 on the Curve data: a straight line cannot follow the wave (underfitting).
  2. 02Turn on the 25% test split and raise the degree to 12: training R² keeps rising while test R² falls (overfitting).
  3. 03Erase a few points at the edges and watch a high-degree curve swing wildly there.

How it works

  1. 1Expand x into features x, x², …, xᵈ.
  2. 2Fit an ordinary least-squares model on those features.
  3. 3Low degrees are too rigid (underfitting); high degrees chase the noise (overfitting).

What the controls teach

Degree
Model flexibility. Each step up adds one more bend the curve can make.

Use it when

  • A smooth, curved relationship with one input

Avoid it when

  • Extrapolating beyond the data
  • High degrees without regularization

More in Regression