---
title: "Discussion on \"An intuitive overview of Gradient Descent\" | Hashnode"
description: "Discussion on \"An intuitive overview of Gradient Descent\". understanding the optimizer function for linear regression"
url: "https://hashnode.com/posts/an-intuitive-overview-of-gradient-descent/602c32ff4bb9c4083f027eb8"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [An intuitive overview of Gradient Descent](https://madelinecaples.hashnode.dev/an-intuitive-overview-of-gradient-descent?utm_source=hashnode&utm_medium=feed)

understanding the optimizer function for linear regression

Feb 16, 2021 · 11 min read · madelinecaples.hashnode.dev  
Read the article

-   [#machine-learning](https://hashnode.com/tag/machine-learning)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#data-science](https://hashnode.com/tag/data-science)

## Written by

[Madeline Caples](https://hashnode.com/@madeline_pc)

@madeline\_pc

  
[View profile](https://hashnode.com/@madeline_pc)

Frontend Developer @FuegoLeads

I'm a frontend developer who likes to write about machine learning and other software engineering topics.

## Responses 1

Markdown supported · ⌘↵ to post

[Marcel Bischoff](https://hashnode.com/@marcelbischoff)

[Feb 19, 2021](https://hashnode.com/posts/an-intuitive-overview-of-gradient-descent/602c32ff4bb9c4083f027eb8/comment/60300aedf51caf44485613cc)

Quick thing: for linear regression you actually don't need gradient descent and you can solve it directly using linear algebra (it's called the Normal Equation in Machine Learning). Here is a sample code I posted on twitter recently:

```
import numpy as np

number_of_flats = (1, 2, 3, 4, 5, 6, 7)
price_of_house = (10000, 20000, 30000, 40000, 50000, 60000, 70000)

A = np.vstack([np.ones(len(number_of_flats)), number_of_flats]).transpose()
b, a = np.linalg.pinv(A.transpose().dot(A)).dot(A.transpose()).dot(price_of_house)
model = lambda x: a*x+b

print(model(10))
```

[Madeline Caples](https://hashnode.com/@madeline_pc)

[Feb 20, 2021](https://hashnode.com/posts/an-intuitive-overview-of-gradient-descent/602c32ff4bb9c4083f027eb8/comment/60300aedf51caf44485613cc#reply-60306ef1f51caf44485616c4)

That is a great point, Marcel! Thanks for contributing this explanation and code. It is always good to look at alternative ways to solve a problem.

Although gradient descent isn't necessary for linear regression, I chose to use it here, partly because gradient descent is just such a useful thing to know in machine learning, and partly because it is something I have been studying lately. 🙂

[Marcel Bischoff](https://hashnode.com/@marcelbischoff)

[Feb 21, 2021](https://hashnode.com/posts/an-intuitive-overview-of-gradient-descent/602c32ff4bb9c4083f027eb8/comment/60300aedf51caf44485613cc#reply-6032d16172a689446db3f326)

Yes, gradient descent is way more important for machine learning, and also if you have a lot of parameters the matrices get too big to efficiently invert them and you are better of with gradient descent. When I started looking into ML I was very confused that linear regression is even considered machine learning. But you can explain a lot of important things with it like gradient descent, supervised learning over/underfitting etc.
