SlideShare a Scribd company logo
Decision Tree In R | Decision Tree Algorithm | Data Science Tutorial | Machine Learning |Simplilearn
What’s in it for you?
What is a Decision Tree?
What problems can be solved using Decision Trees?
How does a Decision Tree work?
Use Case: Survival prediction in R
What is a Decision Tree?
Left or right?
What is a Decision Tree?
Wait or go? Left or right?
What is a Decision Tree?
Decision Tree is a tree shaped algorithm used to determine a course of action.
Each branch of the tree represents a possible decision, occurrence or reaction
Wait or go? Left or right?
What is a Decision Tree?
What is a Decision Tree?
Shopkeeper
What is a Decision Tree?
I must organize
my stall..
Shopkeeper
What is a Decision Tree?
Shopkeeper
What is a Decision Tree?
Is it coloured orange?
Is it round?
No Yes
YesNo
Shopkeeper
What problems can be solved using Decision Tree?
Classification:
Identifying to which set an object belongs
Example: Carrot is orange while broccoli is
green
What problems can be solved using Decision Tree?
Classification:
Identifying to which set an object belongs
Example: Carrot is orange while broccoli is
green
Regression:
Regression problems have continuous or
numerical valued output variables
Example: Predicting the profits of a company
How does a Decision Tree work?
Terms you must know
first…..
How does a Decision Tree work?
NODES
Each internal node in a decision tree is a test which splits the objects into
different categories
Is it coloured orange?
Is it round?
No Yes
YesNo
Terms you must know
first…..
How does a Decision Tree work?
Is it coloured orange?
Is it round?
No Yes
YesNoThis is a node
Terms you must know
first…..
NODES
Each internal node in a decision tree is a test which splits the objects into
different categories
How does a Decision Tree work?
Is it coloured orange?
Is it round?
No Yes
YesNo
ROOT NODE
The node at the top of the decision tree is called the Root node
Terms you must know
first…..
How does a Decision Tree work?
ROOT NODE
The node at the top of the decision tree is called the Root node
Is it coloured orange?
Is it round?
No Yes
YesNo
This is a root node
Terms you must know
first…..
How does a Decision Tree work?
LEAF NODE
Each external node in a decision tree is called the leaf node. The leaf
node is the output
Is it coloured orange?
Is it round?
No Yes
YesNo
Terms you must know
first…..
How does a Decision Tree work?
Is it coloured orange?
Is it round?
No Yes
YesNo
This is a leaf node
LEAF NODE
Each external node in a decision tree is called the leaf node. The leaf
node is the output
Terms you must know
first…..
How does a Decision Tree work?
ENTROPY
Entropy is a measure of the messiness of your data collection. The
messier or more random your data, higher will be the entropy
Terms you must know
first…..
How does a Decision Tree work?
This collection has high entropy
Terms you must know
first…..
ENTROPY
Entropy is a measure of the messiness of your data collection. The
messier or more random your data, higher will be the entropy
How does a Decision Tree work?
This collection has high entropy
This collection has low entropy
Terms you must know
first…..
ENTROPY
Entropy is a measure of the messiness of your data collection. The
messier or more random your data, higher will be the entropy
How does a Decision Tree work?
INFORMATION GAIN
Information gain is the decrease obtained in entropy by splitting the data
set based on some condition
Is it coloured orange?
Is it round?
No Yes
YesNo
E1
E2
Terms you must know
first…..
How does a Decision Tree work?
INFORMATION GAIN
Information gain is the decrease obtained in entropy by splitting the data
set based on some condition
Is it coloured orange?
Is it round?
No Yes
YesNo
E1
E2
E1>E2
INFORMATION GAIN=E1-E2
Terms you must know
first…..
How does a Decision Tree work?
Hi, my cupboard is
a mess. I must
organize my stuff..
How does a Decision Tree work?
Classify the objects based
on their attribute set using
decision trees
How does a Decision Tree work?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Let’s look at the attributes
for each object
How does a Decision Tree work?
• We split at each level based on certain
conditions on the attributes
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
How does a Decision Tree work?
• We split at each level based on certain
conditions on the attributes
• Splitting aims at reducing the entropy
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
How does a Decision Tree work?
• We split at each level based on certain
conditions on the attributes
• Splitting aims at reducing the entropy
-∑ⁱₓ₌₁p(valueₓ).log₂(p(valueₓ))
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
How does a Decision Tree work?
-[2/9.log₂(2/9) + 2/9.log₂(2/9) + 1/9.log₂(1/9) + 4/9.log₂(4/9)]=
-∑ⁱₓ₌₁p(valueₓ).log₂(p(valueₓ))
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
How does a Decision Tree work?
-[2/9.log₂(2/9) + 2/9.log₂(2/9) + 1/9.log₂(1/9) + 4/9.log₂(4/9)]= 1.8282
-∑ⁱₓ₌₁p(valueₓ).log₂(p(valueₓ))
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
How does a Decision Tree work?
Now we must find the conditions
for our split. Every split must give
us the maximum achievable
information gain Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
How does a Decision Tree work?
Our first split will be on
shape as that will
directly segregate the
balls
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
E1 = 1.8282
How does a Decision Tree work?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
E2 = 1.3784
E1 = 1.8282
How does a Decision Tree work?
Our second split will be
on size as that will
directly segregate the
books
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
E2 = 1.3784
E1 = 1.8282
How does a Decision Tree work?
Shape == Rectangle?
Size>5?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
E3 = 0.716
E2 = 1.3784
E1 = 1.8282
How does a Decision Tree work?
Our third split will
once again be on
size
Size>5?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
E3 = 0.716
E2 = 1.3784
E1 = 1.8282
How does a Decision Tree work?
Size>3?
Size>5?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
E3 = 0.716
E2 = 1.3784
E1 = 1.8282
E4 = 0
How does a Decision Tree work?
Size>3?
Size>5?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
E2 = 1.3784
E3 = 0.716
E1 = 1.8282
E4 = 0
How does a Decision Tree work?
All our objects are now
classified with 100%
accuracy
Size>3?
Size>5?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
How does a Decision Tree work?
All our objects are now
classified with 100%
accuracy
Size>3?
Size>5?
Shape Size Label Number
round 10 ball 2
rectangle 6 book 2
rectangle 4 card 1
rectangle 2 blocks 4
total 9
Shape == Rectangle?
Use Case: Survival prediction in R
Let’s implement classification of a data set based on
Information Gain
Let’s implement classification of a data set based on
Information Gain
This is the ID3 algorithm
Use Case: Survival prediction in R
Let’s implement classification of a data set based on
Information Gain
This is the ID3 algorithm
We will be using the RStudio IDE
Use Case: Survival prediction in R
• A ship had 20 lifeboats
Use Case: Survival prediction in R
• A ship had 20 lifeboats
• The lifeboats were
distributed based on the
class, gender and age of
the passengers
Use Case: Survival prediction in R
• A ship had 20 lifeboats
• The lifeboats were
distributed based on the
class, gender and age of
the passengers
• We will develop a model
that recognises the
relationship between these
factors and predicts the
survival of a passenger
accordingly
Use Case: Survival prediction in R
Use Case: Survival prediction in R
We will be using a data set which
specifies if a passenger on a ship
survived it’s wreck or not
1 indicates the
person survived the
wreck
We will be using a data set which
specifies if a passenger on a ship
survived it’s wreck or not
Use Case: Survival prediction in R
The luxury class
of the cabin
Use Case: Survival prediction in R
We will be using a data set which
specifies if a passenger on a ship
survived it’s wreck or not
Numbers of siblings
on board
Use Case: Survival prediction in R
We will be using a data set which
specifies if a passenger on a ship
survived it’s wreck or not
Numbers of parents
on board
Use Case: Survival prediction in R
We will be using a data set which
specifies if a passenger on a ship
survived it’s wreck or not
Disembark location
Use Case: Survival prediction in R
We will be using a data set which
specifies if a passenger on a ship
survived it’s wreck or not
What is DecisionTree? Problems solved using DecisionTrees
How does a decision tree work?
Key Takeaways
Predicting survivors using R Determining accuracy of prediction
Terms to know
So what’s
your next step?
Ad

Recommended

Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Simplilearn
 
Multiclass classification of imbalanced data
Multiclass classification of imbalanced data
SaurabhWani6
 
Erd practice exercises
Erd practice exercises
Jennifer Polack
 
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Simplilearn
 
Random forest and decision tree
Random forest and decision tree
AAKANKSHA JAIN
 
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Simplilearn
 
Facility location planning
Facility location planning
Sanket Kulkarni
 
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
Simplilearn
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Machine Learning with Decision trees
Machine Learning with Decision trees
Knoldus Inc.
 
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Simplilearn
 
Supervised and unsupervised learning
Supervised and unsupervised learning
Paras Kohli
 
Presentation on K-Means Clustering
Presentation on K-Means Clustering
Pabna University of Science & Technology
 
Introduction to Machine Learning Classifiers
Introduction to Machine Learning Classifiers
Functional Imperative
 
K means Clustering Algorithm
K means Clustering Algorithm
Kasun Ranga Wijeweera
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
Machine Learning
Machine Learning
Girish Khanzode
 
Decision Trees
Decision Trees
International School of Engineering
 
K means Clustering
K means Clustering
Edureka!
 
Naive bayes
Naive bayes
Ashraf Uddin
 
Hierarchical clustering
Hierarchical clustering
Ashek Farabi
 
Decision Tree Learning
Decision Tree Learning
Milind Gokhale
 
Intro to machine learning
Intro to machine learning
Tamir Taha
 
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Simplilearn
 
Decision trees in Machine Learning
Decision trees in Machine Learning
Mohammad Junaid Khan
 
Data Analysis: Evaluation Metrics for Supervised Learning Models of Machine L...
Data Analysis: Evaluation Metrics for Supervised Learning Models of Machine L...
Md. Main Uddin Rony
 
K means clustering
K means clustering
keshav goyal
 
13 Machine Learning Supervised Decision Trees
13 Machine Learning Supervised Decision Trees
Andres Mendez-Vazquez
 
Decision Tree-ID3,C4.5,CART,Regression Tree
Decision Tree-ID3,C4.5,CART,Regression Tree
Global Academy of Technology
 

More Related Content

What's hot (20)

Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Machine Learning with Decision trees
Machine Learning with Decision trees
Knoldus Inc.
 
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Simplilearn
 
Supervised and unsupervised learning
Supervised and unsupervised learning
Paras Kohli
 
Presentation on K-Means Clustering
Presentation on K-Means Clustering
Pabna University of Science & Technology
 
Introduction to Machine Learning Classifiers
Introduction to Machine Learning Classifiers
Functional Imperative
 
K means Clustering Algorithm
K means Clustering Algorithm
Kasun Ranga Wijeweera
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
Machine Learning
Machine Learning
Girish Khanzode
 
Decision Trees
Decision Trees
International School of Engineering
 
K means Clustering
K means Clustering
Edureka!
 
Naive bayes
Naive bayes
Ashraf Uddin
 
Hierarchical clustering
Hierarchical clustering
Ashek Farabi
 
Decision Tree Learning
Decision Tree Learning
Milind Gokhale
 
Intro to machine learning
Intro to machine learning
Tamir Taha
 
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Simplilearn
 
Decision trees in Machine Learning
Decision trees in Machine Learning
Mohammad Junaid Khan
 
Data Analysis: Evaluation Metrics for Supervised Learning Models of Machine L...
Data Analysis: Evaluation Metrics for Supervised Learning Models of Machine L...
Md. Main Uddin Rony
 
K means clustering
K means clustering
keshav goyal
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Machine Learning with Decision trees
Machine Learning with Decision trees
Knoldus Inc.
 
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Simplilearn
 
Supervised and unsupervised learning
Supervised and unsupervised learning
Paras Kohli
 
Introduction to Machine Learning Classifiers
Introduction to Machine Learning Classifiers
Functional Imperative
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
K means Clustering
K means Clustering
Edureka!
 
Hierarchical clustering
Hierarchical clustering
Ashek Farabi
 
Decision Tree Learning
Decision Tree Learning
Milind Gokhale
 
Intro to machine learning
Intro to machine learning
Tamir Taha
 
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Simplilearn
 
Decision trees in Machine Learning
Decision trees in Machine Learning
Mohammad Junaid Khan
 
Data Analysis: Evaluation Metrics for Supervised Learning Models of Machine L...
Data Analysis: Evaluation Metrics for Supervised Learning Models of Machine L...
Md. Main Uddin Rony
 
K means clustering
K means clustering
keshav goyal
 

Similar to Decision Tree In R | Decision Tree Algorithm | Data Science Tutorial | Machine Learning |Simplilearn (20)

13 Machine Learning Supervised Decision Trees
13 Machine Learning Supervised Decision Trees
Andres Mendez-Vazquez
 
Decision Tree-ID3,C4.5,CART,Regression Tree
Decision Tree-ID3,C4.5,CART,Regression Tree
Global Academy of Technology
 
CSA 3702 machine learning module 2
CSA 3702 machine learning module 2
Nandhini S
 
Classification Using Decision Trees and RulesChapter 5.docx
Classification Using Decision Trees and RulesChapter 5.docx
monicafrancis71118
 
Data Science Machine LearningClassification.pdf
Data Science Machine LearningClassification.pdf
messagetome133
 
Lect9 Decision tree
Lect9 Decision tree
hktripathy
 
Decision Tree ID3 Algorithm | Decision Tree | ID3 Algorithm | Machine Learnin...
Decision Tree ID3 Algorithm | Decision Tree | ID3 Algorithm | Machine Learnin...
Simplilearn
 
Decision Trees
Decision Trees
Student
 
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Edureka!
 
Data Science-entropy machine learning.pptx
Data Science-entropy machine learning.pptx
ZainabShahzad9
 
supervised machine learning algorithms support vector machine
supervised machine learning algorithms support vector machine
pranalisonawane8600
 
7 decision tree
7 decision tree
tafosepsdfasg
 
Machine Learning 3 - Decision Tree Learning
Machine Learning 3 - Decision Tree Learning
butest
 
Decision tree learning
Decision tree learning
Dr. Radhey Shyam
 
decisiontrees.ppt
decisiontrees.ppt
PriyadharshiniG41
 
decisiontrees.ppt
decisiontrees.ppt
LvlShivaNagendra
 
decisiontrees (3).ppt
decisiontrees (3).ppt
LvlShivaNagendra
 
Understanding Decision Trees in Machine Learning: A Comprehensive Guide
Understanding Decision Trees in Machine Learning: A Comprehensive Guide
CyberPro Magazine
 
[Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees
Nikolaos Vergos
 
Forms of learning in ai
Forms of learning in ai
Robert Antony
 
13 Machine Learning Supervised Decision Trees
13 Machine Learning Supervised Decision Trees
Andres Mendez-Vazquez
 
CSA 3702 machine learning module 2
CSA 3702 machine learning module 2
Nandhini S
 
Classification Using Decision Trees and RulesChapter 5.docx
Classification Using Decision Trees and RulesChapter 5.docx
monicafrancis71118
 
Data Science Machine LearningClassification.pdf
Data Science Machine LearningClassification.pdf
messagetome133
 
Lect9 Decision tree
Lect9 Decision tree
hktripathy
 
Decision Tree ID3 Algorithm | Decision Tree | ID3 Algorithm | Machine Learnin...
Decision Tree ID3 Algorithm | Decision Tree | ID3 Algorithm | Machine Learnin...
Simplilearn
 
Decision Trees
Decision Trees
Student
 
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Edureka!
 
Data Science-entropy machine learning.pptx
Data Science-entropy machine learning.pptx
ZainabShahzad9
 
supervised machine learning algorithms support vector machine
supervised machine learning algorithms support vector machine
pranalisonawane8600
 
Machine Learning 3 - Decision Tree Learning
Machine Learning 3 - Decision Tree Learning
butest
 
Understanding Decision Trees in Machine Learning: A Comprehensive Guide
Understanding Decision Trees in Machine Learning: A Comprehensive Guide
CyberPro Magazine
 
[Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees
Nikolaos Vergos
 
Forms of learning in ai
Forms of learning in ai
Robert Antony
 
Ad

More from Simplilearn (20)

Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Ad

Recently uploaded (20)

VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
 
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
 
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
RAKESH SAJJAN
 
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
RAKESH SAJJAN
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
“THE BEST CLASS IN SCHOOL”. _
“THE BEST CLASS IN SCHOOL”. _
Colégio Santa Teresinha
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
 
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
 
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
RAKESH SAJJAN
 
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
RAKESH SAJJAN
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 

Decision Tree In R | Decision Tree Algorithm | Data Science Tutorial | Machine Learning |Simplilearn

  • 2. What’s in it for you? What is a Decision Tree? What problems can be solved using Decision Trees? How does a Decision Tree work? Use Case: Survival prediction in R
  • 3. What is a Decision Tree?
  • 4. Left or right? What is a Decision Tree?
  • 5. Wait or go? Left or right? What is a Decision Tree?
  • 6. Decision Tree is a tree shaped algorithm used to determine a course of action. Each branch of the tree represents a possible decision, occurrence or reaction Wait or go? Left or right? What is a Decision Tree?
  • 7. What is a Decision Tree? Shopkeeper
  • 8. What is a Decision Tree? I must organize my stall.. Shopkeeper
  • 9. What is a Decision Tree? Shopkeeper
  • 10. What is a Decision Tree? Is it coloured orange? Is it round? No Yes YesNo Shopkeeper
  • 11. What problems can be solved using Decision Tree? Classification: Identifying to which set an object belongs Example: Carrot is orange while broccoli is green
  • 12. What problems can be solved using Decision Tree? Classification: Identifying to which set an object belongs Example: Carrot is orange while broccoli is green Regression: Regression problems have continuous or numerical valued output variables Example: Predicting the profits of a company
  • 13. How does a Decision Tree work? Terms you must know first…..
  • 14. How does a Decision Tree work? NODES Each internal node in a decision tree is a test which splits the objects into different categories Is it coloured orange? Is it round? No Yes YesNo Terms you must know first…..
  • 15. How does a Decision Tree work? Is it coloured orange? Is it round? No Yes YesNoThis is a node Terms you must know first….. NODES Each internal node in a decision tree is a test which splits the objects into different categories
  • 16. How does a Decision Tree work? Is it coloured orange? Is it round? No Yes YesNo ROOT NODE The node at the top of the decision tree is called the Root node Terms you must know first…..
  • 17. How does a Decision Tree work? ROOT NODE The node at the top of the decision tree is called the Root node Is it coloured orange? Is it round? No Yes YesNo This is a root node Terms you must know first…..
  • 18. How does a Decision Tree work? LEAF NODE Each external node in a decision tree is called the leaf node. The leaf node is the output Is it coloured orange? Is it round? No Yes YesNo Terms you must know first…..
  • 19. How does a Decision Tree work? Is it coloured orange? Is it round? No Yes YesNo This is a leaf node LEAF NODE Each external node in a decision tree is called the leaf node. The leaf node is the output Terms you must know first…..
  • 20. How does a Decision Tree work? ENTROPY Entropy is a measure of the messiness of your data collection. The messier or more random your data, higher will be the entropy Terms you must know first…..
  • 21. How does a Decision Tree work? This collection has high entropy Terms you must know first….. ENTROPY Entropy is a measure of the messiness of your data collection. The messier or more random your data, higher will be the entropy
  • 22. How does a Decision Tree work? This collection has high entropy This collection has low entropy Terms you must know first….. ENTROPY Entropy is a measure of the messiness of your data collection. The messier or more random your data, higher will be the entropy
  • 23. How does a Decision Tree work? INFORMATION GAIN Information gain is the decrease obtained in entropy by splitting the data set based on some condition Is it coloured orange? Is it round? No Yes YesNo E1 E2 Terms you must know first…..
  • 24. How does a Decision Tree work? INFORMATION GAIN Information gain is the decrease obtained in entropy by splitting the data set based on some condition Is it coloured orange? Is it round? No Yes YesNo E1 E2 E1>E2 INFORMATION GAIN=E1-E2 Terms you must know first…..
  • 25. How does a Decision Tree work? Hi, my cupboard is a mess. I must organize my stuff..
  • 26. How does a Decision Tree work? Classify the objects based on their attribute set using decision trees
  • 27. How does a Decision Tree work? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Let’s look at the attributes for each object
  • 28. How does a Decision Tree work? • We split at each level based on certain conditions on the attributes Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9
  • 29. How does a Decision Tree work? • We split at each level based on certain conditions on the attributes • Splitting aims at reducing the entropy Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9
  • 30. How does a Decision Tree work? • We split at each level based on certain conditions on the attributes • Splitting aims at reducing the entropy -∑ⁱₓ₌₁p(valueₓ).log₂(p(valueₓ)) Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9
  • 31. How does a Decision Tree work? -[2/9.log₂(2/9) + 2/9.log₂(2/9) + 1/9.log₂(1/9) + 4/9.log₂(4/9)]= -∑ⁱₓ₌₁p(valueₓ).log₂(p(valueₓ)) Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9
  • 32. How does a Decision Tree work? -[2/9.log₂(2/9) + 2/9.log₂(2/9) + 1/9.log₂(1/9) + 4/9.log₂(4/9)]= 1.8282 -∑ⁱₓ₌₁p(valueₓ).log₂(p(valueₓ)) Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9
  • 33. How does a Decision Tree work? Now we must find the conditions for our split. Every split must give us the maximum achievable information gain Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9
  • 34. How does a Decision Tree work? Our first split will be on shape as that will directly segregate the balls Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 E1 = 1.8282
  • 35. How does a Decision Tree work? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle? E2 = 1.3784 E1 = 1.8282
  • 36. How does a Decision Tree work? Our second split will be on size as that will directly segregate the books Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle? E2 = 1.3784 E1 = 1.8282
  • 37. How does a Decision Tree work? Shape == Rectangle? Size>5? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 E3 = 0.716 E2 = 1.3784 E1 = 1.8282
  • 38. How does a Decision Tree work? Our third split will once again be on size Size>5? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle? E3 = 0.716 E2 = 1.3784 E1 = 1.8282
  • 39. How does a Decision Tree work? Size>3? Size>5? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle? E3 = 0.716 E2 = 1.3784 E1 = 1.8282 E4 = 0
  • 40. How does a Decision Tree work? Size>3? Size>5? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle? E2 = 1.3784 E3 = 0.716 E1 = 1.8282 E4 = 0
  • 41. How does a Decision Tree work? All our objects are now classified with 100% accuracy Size>3? Size>5? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle?
  • 42. How does a Decision Tree work? All our objects are now classified with 100% accuracy Size>3? Size>5? Shape Size Label Number round 10 ball 2 rectangle 6 book 2 rectangle 4 card 1 rectangle 2 blocks 4 total 9 Shape == Rectangle?
  • 43. Use Case: Survival prediction in R Let’s implement classification of a data set based on Information Gain
  • 44. Let’s implement classification of a data set based on Information Gain This is the ID3 algorithm Use Case: Survival prediction in R
  • 45. Let’s implement classification of a data set based on Information Gain This is the ID3 algorithm We will be using the RStudio IDE Use Case: Survival prediction in R
  • 46. • A ship had 20 lifeboats Use Case: Survival prediction in R
  • 47. • A ship had 20 lifeboats • The lifeboats were distributed based on the class, gender and age of the passengers Use Case: Survival prediction in R
  • 48. • A ship had 20 lifeboats • The lifeboats were distributed based on the class, gender and age of the passengers • We will develop a model that recognises the relationship between these factors and predicts the survival of a passenger accordingly Use Case: Survival prediction in R
  • 49. Use Case: Survival prediction in R We will be using a data set which specifies if a passenger on a ship survived it’s wreck or not
  • 50. 1 indicates the person survived the wreck We will be using a data set which specifies if a passenger on a ship survived it’s wreck or not Use Case: Survival prediction in R
  • 51. The luxury class of the cabin Use Case: Survival prediction in R We will be using a data set which specifies if a passenger on a ship survived it’s wreck or not
  • 52. Numbers of siblings on board Use Case: Survival prediction in R We will be using a data set which specifies if a passenger on a ship survived it’s wreck or not
  • 53. Numbers of parents on board Use Case: Survival prediction in R We will be using a data set which specifies if a passenger on a ship survived it’s wreck or not
  • 54. Disembark location Use Case: Survival prediction in R We will be using a data set which specifies if a passenger on a ship survived it’s wreck or not
  • 55. What is DecisionTree? Problems solved using DecisionTrees How does a decision tree work? Key Takeaways Predicting survivors using R Determining accuracy of prediction Terms to know

Editor's Notes