The idea
Imagine every point is tied to the line with a little vertical spring. Long springs pull much harder than short ones, because the pull grows with the square of the stretch. The line settles where the total tension is as small as possible.
A polynomial fit is the same trick with extra ingredients. Instead of only , the model may use , and so on, so the curve can bend. The maths does not change: it is still a weighted sum, just of more features.
How it learns
- Turn each into a row of features: , up to the chosen degree.
- Measure the error as the mean of squared residuals, the vertical gaps between points and curve.
- Optionally add a ridge penalty that charges for large weights (the intercept is never penalised).
- Solve the resulting linear equations directly. There is no training loop: the best weights come out in one step.
Reading the picture
The coloured curve is the fitted model. With Show residuals on, each point gets a thin segment to the curve: those are the errors the model is trying to shrink, and the MSE in the stats is their average squared length.
tells you how much better the fit is than a flat line at the mean . For degree 3 or below the stats also print the fitted equation, so you can read the slope and intercept directly.
Try this
- On Line, leave Polynomial degree at 1 and drag a single point far up. Watch the whole line tilt towards it: squared error makes one outlier very loud.
- Switch to Curve and step Polynomial degree from 1 to 2. should jump, because the data really is a parabola.
- Pick Wave, lower the point count, and push Polynomial degree to 12. The curve threads every point and swings wildly between them. Now raise Ridge penalty () and watch it calm down.
- Try Outliers with degree 1 and compare the fit with and without the stray points (shift-click to erase them).
The maths
Model
Loss
Closed form
Residual
R-squared
Strengths and weaknesses
Good at
- Fast, exact and easy to interpret.
- Coefficients tell you how changes with .
- Polynomial features add flexibility without new maths.
Struggles with
- Squared error lets outliers drag the fit around.
- High degrees overfit and explode at the edges.
- You must choose the shape (degree) up front.