Hello, I'm Ganesh. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. Star git-lrc on GitHub to help more developers discover the project. Do give it a try and share your feedback for improving the product.
Linear Regression Line
The line is drawn between two axes, X and Y.
We can draw infinite lines with different points. But only one will be best fit for the given points.
For a set of 2D points (x_i,y_i), the simplest linear regression model is:
y = mx + b
Where:
- (m) = slope
- (b) = intercept
To compute them from your points:
Slope:
m = (n∑xy−(∑x)(∑y)) / (n∑x^2−(∑x)^2)
Intercept:
b = (∑y−m∑x) / n
Then your best-fit line is:
y = mx + b
Calculation of Slope
For example points:
| x | y |
|---|---|
| 1 | 2 |
| 2 | 3 |
| 3 | 5 |
| 4 | 4 |
Result:
m = 0.8
b = 1.5
Best-fit line:
y = 0.8x + 1.5
Finally we get the result:
Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.


Top comments (0)