Skip to content

Commit ca20d2c

Browse files
authored
docs: clarify least-squares intuition
1 parent 70f89e8 commit ca20d2c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

2-Regression/3-Linear/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ As you learned in Lesson 1, the goal of a linear regression exercise is to be ab
4343
- **Show variable relationships**. Show the relationship between variables
4444
- **Make predictions**. Make accurate predictions on where a new datapoint would fall in relationship to that line.
4545

46-
It is typical of **Least-Squares Regression** to draw this type of line. The term 'least-squares' means that all the datapoints surrounding the regression line are squared and then added up. Ideally, that final sum is as small as possible, because we want a low number of errors, or `least-squares`.
46+
It is typical of **Least-Squares Regression** to draw this type of line. The term "Least-Squares" refers to the process of minimizing the total error in our model. For every data point, we measure the vertical distance (called a residual) between the actual point and our regression line.
4747

48-
We do so since we want to model a line that has the least cumulative distance from all of our data points. We also square the terms before adding them since we are concerned with its magnitude rather than its direction.
48+
We square these distances for two main reasons:
49+
50+
1.**Magnitude over Direction:** We want to treat an error of -5 the same as an error of +5. Squaring turns all values positive.
51+
52+
2.**Penalizing Outliers:** Squaring gives more weight to larger errors, forcing the line to stay closer to points that are far away.
53+
54+
We then add all these squared values together. Our goal is to find the specific line where this final sum is at its least (the smallest possible value)—hence the name "Least-Squares".
4955

5056
> **🧮 Show me the math**
5157
>

0 commit comments

Comments
 (0)