Optimization with Gradient Descent

This lesson will focus on how to implement gradient descent algorithm in Python.

We'll cover the following

In the previous lesson, we looked at the intuition behind the gradient descent algorithm and the update equation. In this lesson, we are going to implement it in Python. We are going to predict the tips paid by a customer at a restaurant. We will choose the best model using gradient descent.

Minimization with Gradient Descent

Recall that the gradient descent algorithm is

  • Start with a random initial value of θ\theta.
  • Compute θtαθL(θt,Y)\theta_t - \alpha \frac{\partial}{\partial \theta} L(\theta_t,Y) to update the value of θ\theta.
  • Keep updating the value of θ\theta until it stops changing values. This can be the point where we have reached the minimum of the error function.

We will be using the tips dataset that has the following data.

Get hands-on with 1000+ tech skills courses.

Learn to code, grow your skills, and succeed in your tech interview