Implementing Basic Gradient Descent in Python! #10
Practice it for ML interviews!
I've been getting a lot of requests from my readers to share codes along with the theory in my newsletters. So, I thought of sharing a basic code for implementing gradient descent from scratch in python.
In case, you want to understand the theoretical concept of gradient descent before diving into the code, please refer to the link below:
https://kavitagupta.substack.com/p/gradient-descent-simplified-for-machine
Before we move to the code example, let’s first understand why it is important to practice basic codes of key concepts in machine learning.
Practicing such basic implementations helps solidify your understanding of machine learning concepts.
Many companies ask candidates to write a basic code during interviews to test their coding skills. It doesn't have to be an extensive coding exercise, but having a solid grasp on basic coding along with theoretical knowledge can give you an edge over other candidates.
In the following example, gradient descent is implemented using a very simple univariate function (f(x)= x^2) because the main objective is to understand the implementation. Once you are comfortable with these steps, you can try applying them to more complex functions.
Practicing with different functions and parameters will give you confidence in your coding skills.
Some points to be noted:
Gradient and derivative are same things for a univariate function.
‘learning_rate’ is a hyperparameter which influence the performance of gradient search. You can try using different values of learning_rate and observe its impact on the results.
Please feel free to share your observations on learning_rate using the following button:
Curious about a specific AI/ML topic? Let me know in comments.
Also, please share your feedbacks and suggestions. That will help me keep going. Even a “like” on my posts will tell me that my posts are helpful to you.
See you next Friday!
-Kavita
Quote of the day
Your hardest times often lead to the greatest moments of your life. Keep going. Tough situations build strong people in the end.”
― Roy T. Bennett
P.S. Let’s grow our tribe. Know someone who is curious to dive into ML and AI? Share this newsletter with them and invite them to be a part of this exciting learning journey.



Please do more 'from scratch implementations' for other concepts as well.
This is amazing for building foundations for a beginner. Please bring more such things...often...
Can u also write stuff related to Deep learning?