An example of manually calculating a linear regression for a single variable (x, y) using gradient descent. This demonstrates a basic machine learning linear regression.
In the outputs, compare the values for intercept and slope from the built-in R lm()
method with those that we calculate manually with gradient descent. The plots show how close the red and blue lines overlap.