Skip to main content

Regression Loss Surface

Data Science
Regression
Fit a line by walking downhill on its loss surface.
Author

Apurva Nakade

Published

November 10, 2026

Drag a data point to move it, click the chart to add one, and double-click a point to remove it.

Each line \(y = mx + c\) is a point \((m, c)\), and its loss is a height above that point. The best fit is the lowest point on this surface. With residuals \(r_i = y_i - (m x_i + c)\),

\[ \text{MSE} = \frac{1}{n}\sum_i r_i^2, \qquad \text{MAE} = \frac{1}{n}\sum_i \lvert r_i \rvert . \]

The MSE surface is a bowl with one lowest point, the least-squares line. The MAE surface is made of flat panels, so its minimum can be a whole region, and it is pulled far less by an outlier.

Definition 1 (Gradient descent) From a start \((m_0, c_0)\) and a learning rate \(\eta > 0\), \[ (m_{k+1}, c_{k+1}) = (m_k, c_k) - \eta\, \nabla L(m_k, c_k). \]

The sliders set \((m_0, c_0)\), and the step slider shows \((m_k, c_k)\).

Theorem 1 (Step size for the MSE) The MSE has the constant Hessian \[ H = \frac{2}{n}\sum_i \begin{pmatrix} x_i^2 & x_i \\ x_i & 1 \end{pmatrix}, \] and gradient descent on it converges from every start if and only if \(\eta < 2/\lambda_{\max}(H)\).

The MAE has no such bound: with a fixed step, descent never settles, and keeps jittering around the minimum.