×

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

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.

Top 10 Books on Machine Learning

If you are looking to explore some new domains in engineering field then you may like ML or Machine Learning. The popularity of Machine Learning is increasing gradually day by...

5 minutes read.

Feature engineering for 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. Feature engineering is an important...

6 minutes read.

Overfitting and Underfitting in Machine Learning

We actually talk about prediction errors, which are a measure of a machine learning model's performance and accuracy. Think about the possibility that we are developing a machine learning model....

3 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.

Decision Tree Algorithm in Machine Learning

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

6 minutes read.

Heart Disease Prediction Using Machine Learning

The world uses machine learning in many different fields. This is also true in the healthcare sector. Machine learning may be crucial in determining if locomotor disorders, heart illnesses, and...

12 minutes read.

Feature Selection in Machine Learning

Feature selection Feature selection is the methodology of selecting some particular dataset instead of all the datasets, which is relevant to reducing the noise of machine learning models. In the machine...

3 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.

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.

Basics Vectors in Linear Algebra in ML

First, to learn Machine Learning sincerely, we must know about vectors in Linear Algebra. The principle of Linear Algebra is very much important here. Linear Algebra is the study of...

3 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.

Random Forest Algorithm for Machine Learning

Introduction to Random Forest Random forest is an ensemble-based supervised learning model. The concept of random forest is used in both classifications as well as in the regression problems. Basically, in...

7 minutes read.

PCA 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. PCA is widely used Machine...

3 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.

Kaggle Machine Learning Project

What is Kaggle? Data scientists and machine learning enthusiasts connect online at Kaggle. Users of Kaggle can work together, access and share datasets, use notebooks with GPU integration, and compete with...

6 minutes read.

Best Python Libraries for Machine Learning

Machine Learning is an important technology in modern days. It helps us to do the things which were not possible in previous days. If you have interest in Machine Learning...

8 minutes read.

Machine Learning Classification Algorithm

A supervised machine learning technique called classification uses a model to attempt to predict the right label for a given set of input data. Before being used to make predictions...

6 minutes read.

Pattern Recognition and Machine Learning a MATLAB Companion

The cognitive process that occurs in the brain when it compares the information that we see with the information stored in our memories is called pattern recognition. It is what...

10 minutes read.

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.