FIG. 13 · ATLAS Linear Regression
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.
§ I The fit, live
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.
§ II How it works
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ᵀyIn two dimensions with one feature, the slope and intercept reduce to:
m = (n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²) b = (Σy − m·Σx) / nThat's all the JS does on every drag, every click. The R² readout is 1 − SS_residuals / SS_total — the fraction of variance the line explains.
§ III Where it shines, where it breaks
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.
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.
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.
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.
§ IV Trade-off scorecard
Directional, not exact. These reflect typical behavior on typical-size tabular data; specific architectures move things.
- Inference0.95
- Accuracy0.60
- Training0.95
- Small size0.95
§ V In production
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.
§ VI Compare to
Ridge / Lasso
Linear with regularization · phase 3
Random Forest
Non-linear · tabular accuracy
Decision Tree
A single non-linear regressor