×

Gradient descent algorithm in machine learning

Machine learning

Machine learning algorithms are powerful methods and techniques which are high in terms of probability, and used to give computers high power to compute the solution for large numbers of datasets.

Computers generally use the previous dataset’s result and then compute for the huge, complex current dataset referencing previous datasets.

Gradient descent algorithm

The gradient descent algorithm is the method that gives the local minima or local maxima for a given curve. With the help of this algorithm, we can find out the points of local minima and maxima and use them in the field of machine learning or deep learning to minimize the value of any function.

The gradient Descent Algorithm scales the next point (by a learning rate), subtractions the resulting value from the current position, and repeatedly determines the next point with the gradient at the present position (makes a step). In order to minimize the function, it subtracts the value (to maximize it would be adding).

For a function, if it is differentiable and convex, then only the gradient descent algorithm will work; otherwise, it will not work.

A function to be differentiable means that in its domain, its derivative should be present. For a function to be convex, its double derivative should always be greater than zero.

For example:

Let

Gradient descent algorithm in machine learning

 Now its first derivative would be:

Gradient descent algorithm in machine learning

And its second derivative would be:

Gradient descent algorithm in machine learning

For the above function, the second derivative is two, which is always greater than zero, so it is a strictly convex function.

As we know, in mathematics, we can find out the minima and maxima using differentiation. We find out those points where the first derivative of the curve is zero, and at those points, if the second derivative is positive, then there is a minima, and if the second derivative is negative, then there will be a maxima.

But if the second derivative becomes zero, then that point is neither minima nor maxima and these points are called saddle points. It is the disadvantage of the gradient descent algorithm.

For example:

Let

Now its first derivative is

Gradient descent algorithm in machine learning

The first derivative is zero, so it can be the point of local minima or maxima.

Now its second derivative would be:

Gradient descent algorithm in machine learning

At  X = 0 second derivative is zero, so it is a saddle point.

Working of gradient descent algorithm

Gradient means the slope of the curve. We can evaluate the performance at any time, including the starting position. We will calculate the derivative (or slope) from that starting point, and then we may use a tangent line to determine how steep the slope is. Initially, the slope of the curve is quite steep, but after some time, when other parameters have been introduced, the angle of slope starts reducing until the lowest point of the curve, which is also called the point of convergence.

As in linear regression, our target is to get the line of best fit. The same in the gradient descent algorithm is to reduce the cost of any function as much as possible or reduce the error so much between expected output and actual output. It requires two parameters: the first one is the direction and the second one is the learning rate. These variables impact how future iterations' partial derivative computations are calculated, enabling it to gradually approach the local or global minimum (i.e., point of convergence).

There are the following types of gradient descent algorithms:

1. Batch gradient descent

In batch gradient descent in the training data, it adds the error of each point after evaluation. A training period is a name given to this procedure.

Even while this batching improves computing performance, it can still take a while to analyze big training datasets because all of the data must still be stored in memory. Although batch gradient descent frequently finds the local minimum as opposed to the global one, it also typically yields a steady error gradient and convergence.

2. Stochastic gradient descent

For each sample in the dataset, stochastic gradient descent (SGD) performs a training epoch and updates the parameters one at a time. They are simpler to store in memory since you only need to remember one training example. When compared to batch gradient descent, these frequent updates may provide greater detail and speed, but they may also reduce computational efficiency. Although its frequent updates might lead to noisy gradients, they can also be advantageous for avoiding local minima and locating global ones.

3. Mini-batch gradient descent

This gradient descent is generally combined with the above two batches and stochastic gradient descent. Basically, our input dataset on which we will train our machine learning model will be divided into batches, and on each batch, updates are run. This method creates a balance between stochastic gradient descent's speed and batch gradient descent's computing effectiveness.


Related Topics

Genetic Algorithm in Machine Learning

Genetic algorithm Genetic algorithms are basically search algorithms that are different from conventional search algorithms. Compared to conventional search algorithms, it is based on Darwin's theory of evolution. It is used to...

3 minutes read.

Diabetes Prediction using Machine Learning

Diabetes Mellitus (shortly known as Diabetes) is one of the fastest-growing diseases. Nowadays, many people are affected with diabetes for many reasons, irrespective of age. Recently, many people who belong...

6 minutes read.

Understanding different types of Machine Learning

A machine learns from a trained data set to create a model. Whenever there is a new input to the algorithm, it predicts on the basis of the model. The...

10 minutes read.

Gradient descent algorithm in machine learning

Machine learning Machine learning algorithms are powerful methods and techniques which are high in terms of probability, and used to give computers high power to compute the solution for large numbers...

4 minutes read.

Epoch in Machine Learning

Machine Learning is one of the most used modern technologies in the world. Machine Learning helps human a lot to do their jobs at ease. Epoch is an important concept...

3 minutes read.

Standardization in Machine Learning

In machine learning, we train our data to anticipate or categorize things in ways that aren't pre-programmed into the computer. As a result, firstly, the dataset or input data must...

6 minutes read.

Linear Regression in Machine learning

What is Linear Regression? Linear regression is the most important statistical algorithm in machine learning to learn the correlation between a dependent variable and one or more independent features. So, we...

13 minutes read.

Python Anaconda setup

Python programming language is used in this tutorial to get hands-on machine learning. A compatible IDE (Integrated Development Environment) is needed to be installed on the computer system before using...

3 minutes read.

Machine Learning IDE

IDE (Integrated Development Environment) is a software that is used for the development of software. It usually compiled up of common development tools such as source code editor, compiler, and...

6 minutes read.

Logistic Regression in Machine learning

The Logistic regression model is a supervised learning model that is used to forecast the possibility of a target variable. The dependent variable would have two classes, or we can...

9 minutes read.

Regularization in Machine Learning

We are very familiar with the word Machine Learning nowadays. Machine Learning technologies are used in everywhere. Many IT companies use this type of technologies to improve their product. In...

3 minutes read.

Dimensionality Reduction in machine learning

What is Dimensionality? This word is generated from the word ‘dimension'. So as we know, machine learning is entirely dependent on a vast dataset, and there are a lot of variables...

3 minutes read.

Machine Learning Life Cycle

Machine learning has made it possible for computer systems to learn without explicit programming. However, how do machine learning systems operate? Therefore, it might be explained by the machine learning...

5 minutes read.

Machine Learning Techniques

In today's world, we are surrounded by machines and different types of gadgets. Machine learning is a technique which prepares machines to think and learn. In modern days machine learning...

6 minutes read.

Difference between AI/ ML/ Deep Learning

Nowadays, people are very much confused with the terms artificial intelligence, machine learning, and deep learning. For them, it seems to be that all these three concepts are the same,...

11 minutes read.

Hands-on Machine Learning with Scikit-Learn, TensorFlow, and Keras

"Hands-On Machine Learning with Scikit-Learn and TensorFlow Keras" by Aurélien Géron is the best for you if you're comfortable with Python coding and want a fast introduction to both traditional...

4 minutes read.

Supervised Machine Learning

What is Supervised Machine Learning? In Supervised learning, the machine is trained with the help of well-labeled training data, i.e., the data is tagged with the truthful answer. In other words,...

8 minutes read.

Convolutional Neural Network (CNN) in Machine Learning

Machine Learning  is one of the most used modern technologies in our world. Machine Learning  helps human a lot to do their jobs at ease. Today almost every big tech...

3 minutes read.

Boosting in Machine Learning

Machine Learning and Artificial Intelligence are one of the major modern technologies. In Machine Learning, we mainly develop a model by a Machine Learning algorithm which can predict something. In...

3 minutes read.

Association Rule Learning Algorithm

Introduction to Association Rule Learning Association rule learning extracts alliances among the datapoints in a huge dataset. It incorporates the concept of data mining, which helps in finding useful commercial associations or regularities between the...

3 minutes read.