Vol. XII · No. 05 · May 2026
Jake Cuth.
← from the Model Atlas

The line of
best fit.

Closed-form least squares. Every output is a weighted sum of inputs plus a bias. The baseline every other regressor is measured against — and often the right answer.

Click anywhere on the canvas to add a point. Drag any point to move it. The line refits via closed-form OLS on every change. Three preset datasets demonstrate where the model shines and where it breaks.


Solid red line is the OLS fit. Faint dashed verticals are residuals — the distances OLS minimizes. Try the parabola preset to feel the model's primary failure mode.

click to add · drag to move

Linear regression finds the line that minimizes the sum of squared vertical distances from each point to the line. Those distances are the dashed verticals you see in the demo — the residuals. Squaring them weights large mistakes more than small ones, which is why a single outlier can drag the whole line off course.

The closed-form solution is a single matrix inversion. No gradient descent, no learning rate, no training loop. On reasonably-sized data it returns the optimal line in a fraction of a millisecond. That speed is one of the reasons it is still the right answer surprisingly often.

The math

For inputs X and targets y, OLS solves:

β̂ = (XᵀX)⁻¹ Xᵀy

In two dimensions with one feature, the slope and intercept reduce to:

m = (n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²)     b = (Σy − m·Σx) / n

That's all the JS does on every drag, every click. The readout is 1 − SS_residuals / SS_total — the fraction of variance the line explains.


Shines

Calibrated baselines

Anywhere a small, fast, interpretable predictor is worth more than two extra points of accuracy. Pricing models, capacity forecasts, instrumented A/B baselines, anything where the coefficient table itself is the deliverable.

Shines

Linear-ish phenomena

When the underlying relationship really is roughly linear (after a sensible transform), no fancier model will beat OLS by enough to justify the loss in interpretability and speed.

Breaks

Non-linear truth

Try the parabola preset above. The best line through a curve is always the wrong line through every part of the curve. The residuals show a clear pattern — that pattern is the model telling you to use something non-linear.

Breaks

Outlier domination

Drop a point in the corner of the canvas. The whole line tilts toward it. Squaring the residuals means a single point ten units away pulls the fit a hundred times harder than ten points one unit away. Robust regression replaces the squared loss with Huber or absolute loss to fix this.


Directional, not exact. These reflect typical behavior on typical-size tabular data; specific architectures move things.

INFERENCE ACCURACY TRAINING SIZE
  • Inference0.95
  • Accuracy0.60
  • Training0.95
  • Small size0.95

Zillow's Zestimate (early versions). Linear regression on hand-engineered features — square footage, bedrooms, school ratings, nearby comps — was the entire engine behind the first generations of automated home valuations. Modern versions stack gradient boosting on top, but the linear baseline still drives the residual analysis that catches model drift.


Try the wizard again →