Decision Tree & Random Forest(Machine Learning)

Vatsal Sharma
3 min readJun 21, 2021

--

Decision Tree

IMG Credits- Google Images

Decision Tree is a Supervised Machine Learning algorithm used for predicting outcomes on certain rules/instructions & is done by partitioning data into various subsets. As it’s name suggest, Decision Tree is a tree-like model of decisions & their outcomes.

What it does?

Decision Tree typically starts from a single node and then diverges into it’s various branches. In Machine Learning it is used to solve the problem by dividing data in subsets, It begins with a Root Node & according to the conditions it moves down further. If the condition is true, the True node is preferred & vice-versa, it continues to exceute until the last node is reached.

IMG Credits- Google Images

The above figure is a simple representation of Decision Tree.

Decision Tree’s Root Node is determined by various methods, we can do so by calculating Entropy & Information Gain. Label with the highest Information Gain is selected as the root node.

Applications

  • Healthcare Management.
  • Bank Sector.
  • Fraud Detections.

and many more…

Using Decision Tree

Way 1- Directly importing from scikit learn library in Python.

Input- from sklearn.tree import DecisionTreeClassifier

Way 2- Building Decision Tree model from scratch.

Limitations

  • They’re unstable.
  • They’re often relatively inaccurate
  • Generally leads to overfitting of Data.

etc…

Here, Random Forest comes into the picture.

IMG Credits- Dream Girl

Picture says: Are these both different from each other?

The answer is YES!

Random Forest

IMG Credits- Memegenerator

Random forest is basically, alot of Decision Trees combined together. A random forest is an estimator that fits a number of decision trees on various sub-samples of the dataset and it uses averaging to improve the predictive accuracy and control over-fitting.

What it does?

Random forest classifier creates a set of decision trees from randomly selected subset of training data. It then receives the votes from all Decision Trees & finally aggregates to pass the final decision.

IMG Credits- corporatefinanceinstitute.com

The above diagram represents the working of Random Forest.

Applications

  • Recommendation engines
  • Image Classification
  • Feature Selection

and many more….

Using Random Forest Classifier

Way 1- Directly importing from scikit learn library in Python.

Input- from sklearn.ensemble import RandomTreeClassifier

Way 2- Building Random Forest model from scratch.

Miscellaneous

No doubt, Life is a Random Forest but we have the power to make our Decisions & those decisions can propel us to new possibilities. Life is nothing but, the reflection of our decisions. “Life is Meant to be LIVED”, either you win or you learn.

Refer to- https://medium.com/@bhartendudubey/life-is-meant-to-be-lived-80356033c156

Happy Learning Folks!

You can also visit my previous blogs by clicking on their name below-

Follow me on LinkedIn- https://www.linkedin.com/in/imvat18/

--

--

Vatsal Sharma
Vatsal Sharma

Written by Vatsal Sharma

Building Yarnit 🚀 | SDE-I @Yarnit | Ex- Data Science Intern @Aiotize | JIIT'22 | Aficionado 🏏 https://www.linkedin.com/in/imvat18/

No responses yet