Interactive Lab · AI/ML Foundations

How does a model draw the single "best" line through the data?

A cloud of points, and infinitely many lines you could draw. Regression picks one, the line that makes the total squared error as small as possible. Every point pulls the line toward itself, and squaring the misses means far-off points pull hardest. Drag the knobs, hunt for the low point, then let the math snap to it.

🎬 Watch the 90-second explainer, then drag the line and try to beat the fit below ↓

▶ The playground, tilt the line, shrink the errors

SSE = 0.0above minimum +0.0R² = 0.00line: y = 0.00·x + 0.0
-1 · downhillsteep · 4
-2040

🧭 Where this fits

Linear regression remains the workhorse of quantitative decision-making: pricing models, marketing-mix attribution, forecasting baselines, A/B-test effect estimation, and the final layer of many neural networks. The outlier-hijacks-the-fit effect you just produced is why real pipelines Winsorize, use robust losses, or investigate every influential point.

The code that's actually running



  

🔮 Predict, then test

Before clicking Fit, eyeball the cloud and guess where the best line will sit: what slope, roughly what height? Hit Fit and check. Now click Add outlier and re-fit: which way does the line tilt, and why does one bad point move it so much? (Hint: the error is squared, a point twice as far off hurts four times as much.)

The takeaway

Your new mental model of regression