What Does Linear Regression Minimize?

Fitting a regression line means choosing a slope and an intercept. The three demonstrations below separate those choices before combining them into one loss surface.

Stage 1: Change the Slope

The intercept stays fixed while the slope rotates the line. Each possible slope maps to one point on the mean squared error parabola.

Data space

Intercept fixed at its best value

Error versus slope

Current line
Current MSE
Minimum MSE
Distance from minimum

Stage 2: Change the Intercept

Now the slope stays fixed while the intercept moves the line vertically. The error again forms a parabola, with the best intercept at its lowest point.

Data space

Slope fixed at its best value

Error versus intercept

Current line
Current MSE
Minimum MSE
Distance from minimum

Stage 3: Fit Slope and Intercept Together

Both parameters are free in the final view. The two parabolas become a quadratic bowl, and every slope-intercept pair corresponds to one point on its surface.

Data space

Both parameters are adjustable

Error surface

Current line
Current MSE
Minimum MSE
Distance from minimum

All three demonstrations use the same points. Choosing New shared data in any section updates and resets all three so the comparisons remain consistent.

Putting the Views Together

Every move in parameter space changes the fitted line. That changes the residuals in data space, and their squared values determine the height of the error curve or surface.

Previous post Back to all posts