Skip to content
AI360Xpert
Visual Explainers
Visual explainer

Linear Regression

Fit a straight line through scattered data points by minimising the vertical errors, giving a single trend for prediction.

We have scattered data points and need to find the overall trend to predict new values.
We have scattered data points and need to find the overall trend to predict new values.

When data scatters across a chart, you need a single rule to summarise it. You want to draw the one straight line that captures the central tendency, cutting through the noise.

Just Two Numbers

A straight line is defined by just two numbers: where it starts (intercept) and how steep it is (slope).
A straight line is defined by just two numbers: where it starts (intercept) and how steep it is (slope).

Any straight line is fully described by an intercept and a slope. The model doesn't memorise the data; it just learns these two numbers.

Minimise the Errors

The line adjusts itself to make the vertical distances between the points and the line as small as possible.
The line adjusts itself to make the vertical distances between the points and the line as small as possible.

The best line is the one that sits closest to all points simultaneously. It minimises the sum of the squared vertical distances — the residuals — between the real data and the prediction.

Predicting the Unseen

Once fitted, the line gives us a prediction for any input we haven't seen before.
Once fitted, the line gives us a prediction for any input we haven't seen before.

With the line locked in place, you can drop any new input onto the horizontal axis, trace it up to the line, and read the predicted output off the vertical axis.

Where It Breaks

One single extreme outlier pulls the entire line toward itself, ruining predictions for everyone else.
One single extreme outlier pulls the entire line toward itself, ruining predictions for everyone else.

Because the line cares about squared errors, a single point that lies far away pulls disproportionately hard. One bad outlier will tilt the entire line away from the true trend.

The Quick Version

  • You need one trend for scattered data.
  • A line is just a slope and an intercept.
  • The fit minimises the vertical errors.
  • New predictions just read off the line.
  • Outliers drag the whole line off course.