> For the complete documentation index, see [llms.txt](https://alvintoh.gitbook.io/machine-learning-a-z-hands-on-python-r-in-data-sci/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alvintoh.gitbook.io/machine-learning-a-z-hands-on-python-r-in-data-sci/section-4-simple-linear-regression/23.-simple-linear-regression-intuition-step-2.md).

# 23. Simple Linear Regression Intuition - Step 2

## SIMPLE LINEAR REGRESSION 2

### Ordinary Least Squares

* To get this best fitting line, you take the each of the points on the line, you square them and you take the sum of the squares
* So you got to find the minimum of the sum of the squares
* The formula is SUM (y - y^)^2 -> min
* So basically what a simple linear regession does is it draws lots and lots of these lines
* These trend lines all this is like a simplistic way of imagining the linear regression. and it draws all possible trendlines through the dots and counts the sum of those squares every single time.
* It then finds the minimum one so it looks for the minimum sum of squares and finds a line which has the smallest sum of squares possible
* And that line will be the best fitting line and that is called the ordinary least squares method.
