Algorithms Explained!
The third session of the Empower project included a discussion around various algorithms.
Random Forest Algorithm
Random Forest Algorithm is a method that operates by constructing multiple decision trees during the training phase of the dataset and helps in classifying the query.It is commonly used in predictive modelling and machine learning technique.
In Random forest we select m number of features from total features that are there in the original dataset. Then we try to find the best split point among the m features selected. Split the node into two daughter nodes using the best split. Repeat this process until m number of nodes are reached. This is one decision tree that gets created. Like this n number of trees are created for the forest.
Working Example
Considering this example in which students are given class on the basis of whether he has passed or failed in some subjects.
We have to find out which class Ram belongs to given that Ram passed in Maths, failed in Science, passed in English, and failed in Hindi.
For classifying the above query we will create n number of decision trees as shown in figure below. We will see what is the conclusion from each tree for the given query and the class with the maximum number of votes will the class allotted to Ram.
Advantages of Random Forest Algorithm
- It can be used for both regression and classification tasks, and it’s also easy to view the relative importance it assigns to the input features.
- Random Forest gives high accuracy on large dataset.
- No overfitting — Use of multiple trees reduces the risk of overfitting.
- Estimates the missing data — It maintains accuracy when a large proportion of data is missing.
Bubble Sort
It is an algorithm which will sort the unsorted list. The basic concept is it will check the adjacent elements and swap them if they are out of order in every pass/iteration. It will go over the entire list as many times as the elements.
After every pass the highest element bubbles to the correct position that is why it is called Bubble Sort algorithm.
I have taken an example below to illustrate the algorithm.