When we fit a straight line to data points by least squares, what exactly is the line trying to make small?
Supervised learning, Linear regression
Level L1 Beginner. Length One-liner. Nature Th Theoretical.
What's being asked
Whether you know what a residual is and what quantity least squares minimises, before any matrices or geometry.
Key idea
For each point, the residual is the vertical gap between the actual value and the value the line predicts, . Least squares picks the line that makes the sum of the squared residuals as small as possible.
Steps
- Draw a few dots and one line through them. For each dot, measure the vertical gap to the line. This gap is the residual: actual value minus predicted value.
- Square each gap so that gaps above and below the line cannot cancel each other, and so that big misses count more than small ones.
- Add the squares. Example: a line predicts for three points whose actual values are . The residuals are , so the sum of squares is . Least squares chooses the line (its slope and intercept) with the smallest such total.
Common mistakes
- Measuring the gap perpendicular to the line. Ordinary least squares uses the vertical gap, because we are predicting from .
- Adding the plain residuals. Positive and negative gaps would cancel and a bad line could look perfect.
How long your answer should be
2 sentences, under 30 seconds.
Read this
Previous in Supervised learning: none
Next in Supervised learning: A model scores each student with a number (positive leans towards "will pass", negative towards "will fail"). Why does logistic regression pass through the sigmoid function , and what does the output mean? For example, what does become?