AI & ML Atlas
Machine LearningalgorithmInteractive simulation
Polynomial Regression
Fits a curve by using powers of the input as extra features.
The idea
Create features x, x², x³ … and run ordinary linear regression on them. The model is still linear in its weights but can bend. A low degree underfits, a very high degree chases noise (overfits), so the degree is a model-complexity dial.
ŷ = w₀ + w₁x + w₂x² + … + w_d xᵈ
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- training data
- true curve (dashed)
- fitted curve
Degree 1: too stiff to follow the curve (underfitting). Both errors are high.
- degree:
- 1
- train error:
- 0.0382
- test error:
- 0.033
1/9
Watch the fitted curve as the degree rises: past the true shape it starts chasing noise.
Step by step
- 1Choose a degree d.
- 2Expand each x into [1, x, x², … xᵈ].
- 3Fit linear regression to the expanded features.
- 4Check the error on held-out data to choose d.
Where it is used
Smooth curves in physics, growth trends, calibration.
Watch out for
High degrees oscillate wildly between and beyond the data points.