Professional Documents
Culture Documents
40 2
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 1/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Table of contents
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 4/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 5/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 8/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 9/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 10/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 12/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 16/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Here,
p+ is the probability of positive class
p– is the probability of negative class
S is the subset of the training example
How do Decision Trees use Entropy?
Now we know what entropy is and what is its formula,
Next, we need to know that how exactly does it work in
this algorithm.
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 17/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 18/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
For feature 3,
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 19/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
We can clearly see from the tree itself that left node has
low entropy or more purity than right node since left node
has a greater number of “yes” and it is easy to decide
here.
Always remember that the higher the Entropy, the lower
will be the purity and the higher will be the impurity.
As mentioned earlier the goal of machine learning is to
decrease the uncertainty or impurity in the dataset, here
by using the entropy we are getting the impurity of a
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 20/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 22/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 23/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Our parent entropy was near 0.99 and after looking at this
value of information gain, we can say that the entropy of
the dataset will decrease by 0.37 if we make “Energy” as
our root node.
Similarly, we will do this with the other feature
“Motivation” and calculate its information gain.
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 24/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 25/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
topics with our Black Belt Plus Program with out 50+
projects and 20+ tools. Start your learning journey today!
Frequently Asked Questions
Q1. What is decision tree and example?
A. A decision tree is a tree-like structure that represents a
series of decisions and their possible consequences. It is
used in machine learning for classification and regression
tasks. An example of a decision tree is a flowchart that
helps a person decide what to wear based on the weather
conditions.
Q2. What is the purpose of decision tree?
A. The purpose of a decision tree is to make decisions or
predictions by learning from past data. It helps to
understand the relationships between input variables and
their outcomes and identify the most significant features
that contribute to the final decision.
Q3. What are the 4 types of decision tree?
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 30/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 31/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Anshul Saini
05 Jan 2024
I am an undergraduate student currently in my last year
majoring in Statistics (Bachelors of Statistics) and have a
strong interest in the field of data science, machine
learning, and artificial intelligence. I enjoy diving into data
to discover trends and other valuable insights about the
data. I am constantly learning and motivated to try new
things.
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 32/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Submit reply
Rashi Khandelwal
14 Dec, 2021
Hey Anshul, Just wanted to appreciate you for an
amazing explanation about theoretical concepts
behind decision tree. The crisp clarity and easy, simple
and relatable examples made the understanding better
to core. Thank You
Saurabh Prasad
11 May, 2022
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 33/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 34/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Company Discover
About Us Blogs
Contact Us Expert session
Careers Podcasts
Comprehensive Guides
Learn Engage
Free courses Community
Learning path Hackathons
BlackBelt program Events
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 35/36
2/14/24, 5:56 PM Decision Tree - A Step-by-Step Guide
Download App
https://www.analyticsvidhya.com/blog/2021/08/decision-tree-algorithm/ 36/36