# The gradient descent algorithm is an approach to find an optimal solution for a given dataset. Ashwin Sharma P

2 years ago | 2 min read

The gradient descent algorithm is an approach to find the minimum point or optimal solution for a given dataset. It follows the steepest descent approach. That is it moves in the negative gradient direction to find the local or global minima, starting from a random point. We use gradient descent to reach the lowest point of the cost function.

In Machine Learning, it is used to update the coefficients of our model. It also ensures that the predicted output value is close to the expected output.

For example, in Linear Regression, where we separate the output using a linear equation.

Let us say we have an equation y=mx+c.

Here, m stands for slope and c for the y-intercept. These two values can be optimized and the error in the cost function (the difference between expected and predicted output) can be reduced using the gradient descent algorithm.

## Weight updation

So let us see how weight updation works in gradient descent. Let us consider a graph of cost function vs weight. For improving our model, bringing down the value of the cost function is essential. We consider the lowest point in the graph as the winner since the cost function would be minimal at this point.

In the above diagram, we can see that with each iteration, the function tries to bring down the cost value. But that is not the case in real-world datasets. In real-world cases, it moves in a zig-zag manner for most of the datasets. The graph for real-world cases is shown below.

## What is the maths behind it?

The weight updation takes place by decrementing the cost function in steps of the gradient (derivative) of the weight function. The equation used for weight updation is:

Here ω corresponds to the weight and η the learning rate, which determines by what value the descent is made in each iteration.

For every cross mark shown in the graph, we calculate the slope. According to the slope value, we update the weights in the above equation.

## Conclusion

Here is a sequence diagram to brief the process of updating the weights. This update in weights leads to a reduction in the cost function.

Upvote Created by

Ashwin Sharma P

Loves Artificial Intelligence, philosophy and reading Post

Upvote

Downvote

Comment

Bookmark

Share

Related Articles
{"ft_lang_label":"__label__en","ft_lang_prob":0.87871665,"math_prob":0.97592497,"size":2420,"snap":"2023-14-2023-23","text_gpt3_token_len":495,"char_repetition_ratio":0.14652318,"word_repetition_ratio":0.033898305,"special_character_ratio":0.19338843,"punctuation_ratio":0.08817204,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99808586,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-04-01T14:11:49Z\",\"WARC-Record-ID\":\"<urn:uuid:3406f630-2845-4289-9570-00545773a07e>\",\"Content-Length\":\"72837\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:920dab16-9915-480c-bbcd-87b40bec6ab1>\",\"WARC-Concurrent-To\":\"<urn:uuid:49fc1d6a-042a-4b37-bea9-7458bdd0030b>\",\"WARC-IP-Address\":\"76.76.21.21\",\"WARC-Target-URI\":\"https://tealfeed.com/beginners-guide-gradient-descent-algorithm-7e3d2\",\"WARC-Payload-Digest\":\"sha1:XYDRRTUSYDEQPAA76SB7RJBBZUI2666V\",\"WARC-Block-Digest\":\"sha1:JXJJRSAVG5L7PH5X4ETMD4GGDR3QY477\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296950030.57_warc_CC-MAIN-20230401125552-20230401155552-00788.warc.gz\"}"}