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
- 01Set degree 1 on the Curve data: a straight line cannot follow the wave (underfitting).
- 02Turn on the 25% test split and raise the degree to 12: training R² keeps rising while test R² falls (overfitting).
- 03Erase a few points at the edges and watch a high-degree curve swing wildly there.
How it works
- 1Expand x into features x, x², …, xᵈ.
- 2Fit an ordinary least-squares model on those features.
- 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
Linear regression
Fits the straight line that minimises the squared distance between predictions and the data.
Ridge & lasso regression
A flexible polynomial kept in check by a penalty on large coefficients.
k-nearest neighbours regression
Predicts by averaging the targets of the k closest training points.