Least squares

Choosing the line that gives the smallest possible mean squared error.

For straight lines there is a neat shortcut: a formula that solves least squares directly, jumping straight to the slope and intercept with the smallest possible squared error.
From Fitting a line, step “Let the computer find the best line”

See it in action

Try least squares hands-on in the lesson Fitting a line, part of the AI fundamentals course.

Open the lesson