SlideShare ist ein Scribd-Unternehmen logo
1 von 19
DECISION TREE
Content
 What is decision tree?
 Example
 How to select the deciding node?
 Entropy
 Information gain
 Gini Impurity
 Steps for Making decision tree
 Pros.
 Cons.
What is decision tree?
 Decision tree is the most powerful and
popular tool for classification and prediction.
A Decision tree is a flowchart like tree
structure, where each internal node
denotes a test on an attribute, each branch
represents an outcome of the test, and
each leaf node (terminal node) holds a
class label.
 It is a type of superised learning algorithm.
 It is one of the most widely used and
practical method for inductive inference
Example
 Let's assume we want to play
badminton on a particular day — say
Saturday — how will you decide
whether to play or not. Let's say you
go out and check if it's hot or cold,
check the speed of the wind and
humidity, how the weather is, i.e. is it
sunny, cloudy, or rainy. You take all
these factors into account to decide if
you want to play or not.
So, you calculate all these factors for the last ten days
and form a lookup table like the one below.
Day Weather Temperature Humidity Wind
1 Sunny Hot High Weak
2 Cloudy Hot High Weak
3 Sunny Mild Normal Strong
4 Cloudy Mild High Strong
5 Rainy Mild High Strong
6 Rainy Cool Normal Strong
7 Rainy Mild High Weak
8 Sunny Hot High Strong
9 Cloudy Hot Normal Weak
10 Rainy Mild High Strong
 A decision tree would be a great way to represent
data like this because it takes into account all the
possible paths that can lead to the final decision by
following a tree-like structure.
How to select the deciding
node?
Which is the best Classifier?
So,we can conclude
 Less impure node requires less
information to describe it.
 More impure node requires more
information.
 Information theory is a measure to
define this degree of disorganization in
a system known as Entropy.
Entropy - measuring
homogeneity of a learning set
 Entropy is a measure of the uncertainty about a
source of messages.
 Given a collection S, containing positive and
negative examples of some target concept, the
entropy of S relative to this classification.
where, pi is the proportion of S belonging to class i
Entropy is 0 if all
the members of S
belong to the same
class.
Entropy is 1 when
the collection
contains an equal
no. of +ve and -ve
examples.
Entropy is between
0 and 1 if the
collection contains
unequal no. of +ve
and -ve examples.
Information gain
 Decides which attribute goes into a
decision node.
 To minimize the decision tree depth,
the attribute with the most entropy
reduction is the best choice!
 They are of 2 types-
1. High Information Gain
2. Low Information Gain
 The information gain, Gain(S,A) of an attribute .
Where:
S is each value v of all possible values of attributeA Sv = subset of
S for which attribute A has valuev
|Sv| = number of elements in Sv
|S| = number of elements in S
High Information Gain
 An attribute with high information gain splits the
data into groups with an uneven number of
positives and negatives and as a result helps in
separating the two from each other.
Low Information Gain
 An attribute with low information gain
splits the data relatively evenly and as
a result doesn’t bring us any closer to
a decision.
Gini Impurity
 Gini Impurity is a measurement of the
likelihood of an incorrect classification of a new
instance of a random variable, if that new
instance were randomly classified according to
the distribution of class labels from the data
set.
 If our dataset is Pure then likelihood of
incorrect classification is 0. If our sample is
mixture of different classes then likelihood of
incorrect classification will be high.
 They are of 2 types
 Pure means, in a selected sample of
dataset all data belongs to same class.
 Impure means, data is mixture of different
classes.
Steps for Making decision tree
 Get list of rows (dataset) which are taken into
consideration for making decision tree (recursively
at each nodes).
 Calculate uncertanity of our dataset or Gini
impurity or how much our data is mixed up etc.
 Generate list of all question which needs to be
asked at that node.
 Partition rows into True rows and False rows based
on each question asked.
 Calculate information gain based on gini impurity
and partition of data from previous step.
 Update highest information gain based on each
question asked.
 Update best question based on information gain
(higher information gain).
 Divide the node on best question. Repeat again
from step 1 again until we get pure node (leaf
Pros.
 Easy to use and understand.
 Can handle both categorical and
numerical data.
 Resistant to outliers, hence require
little data preprocessing.
Cons.
 Prone to overfitting.
 Require some kind of measurement
as to how well they are doing.
 Need to be careful with parameter
tuning.
 Can create biased learned trees if
some classes dominate.
Decision tree

Weitere ähnliche Inhalte

Was ist angesagt?

Decision Tree - C4.5&CART
Decision Tree - C4.5&CARTDecision Tree - C4.5&CART
Decision Tree - C4.5&CART
Xueping Peng
 
Slide3.ppt
Slide3.pptSlide3.ppt
Slide3.ppt
butest
 
Understanding random forests
Understanding random forestsUnderstanding random forests
Understanding random forests
Marc Garcia
 

Was ist angesagt? (20)

Decision Trees
Decision TreesDecision Trees
Decision Trees
 
Random forest
Random forestRandom forest
Random forest
 
Decision tree
Decision treeDecision tree
Decision tree
 
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
 
Data preprocessing using Machine Learning
Data  preprocessing using Machine Learning Data  preprocessing using Machine Learning
Data preprocessing using Machine Learning
 
Decision Tree - C4.5&CART
Decision Tree - C4.5&CARTDecision Tree - C4.5&CART
Decision Tree - C4.5&CART
 
Slide3.ppt
Slide3.pptSlide3.ppt
Slide3.ppt
 
2.2 decision tree
2.2 decision tree2.2 decision tree
2.2 decision tree
 
Decision Trees for Classification: A Machine Learning Algorithm
Decision Trees for Classification: A Machine Learning AlgorithmDecision Trees for Classification: A Machine Learning Algorithm
Decision Trees for Classification: A Machine Learning Algorithm
 
From decision trees to random forests
From decision trees to random forestsFrom decision trees to random forests
From decision trees to random forests
 
Understanding random forests
Understanding random forestsUnderstanding random forests
Understanding random forests
 
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
 
Introduction to Machine Learning Classifiers
Introduction to Machine Learning ClassifiersIntroduction to Machine Learning Classifiers
Introduction to Machine Learning Classifiers
 
Presentation on K-Means Clustering
Presentation on K-Means ClusteringPresentation on K-Means Clustering
Presentation on K-Means Clustering
 
Decision tree
Decision treeDecision tree
Decision tree
 
introduction to data mining tutorial
introduction to data mining tutorial introduction to data mining tutorial
introduction to data mining tutorial
 
Classification in data mining
Classification in data mining Classification in data mining
Classification in data mining
 
Random Forest and KNN is fun
Random Forest and KNN is funRandom Forest and KNN is fun
Random Forest and KNN is fun
 
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
 
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain RatioLecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
 

Ähnlich wie Decision tree

BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docxBUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
curwenmichaela
 
Handout11
Handout11Handout11
Handout11
butest
 
Statistics for management
Statistics for managementStatistics for management
Statistics for management
John Prarthan
 
Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)
Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)
Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)
Sherri Gunder
 
coppin chapter 10e.ppt
coppin chapter 10e.pptcoppin chapter 10e.ppt
coppin chapter 10e.ppt
butest
 

Ähnlich wie Decision tree (20)

Decision tree
Decision tree Decision tree
Decision tree
 
Machine learning session6(decision trees random forrest)
Machine learning   session6(decision trees random forrest)Machine learning   session6(decision trees random forrest)
Machine learning session6(decision trees random forrest)
 
Dbm630 lecture06
Dbm630 lecture06Dbm630 lecture06
Dbm630 lecture06
 
Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees
 
Decision Tree.pptx
Decision Tree.pptxDecision Tree.pptx
Decision Tree.pptx
 
10 decision tree
10 decision tree10 decision tree
10 decision tree
 
Desicion tree and neural networks
Desicion tree and neural networksDesicion tree and neural networks
Desicion tree and neural networks
 
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docxBUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
 
Forms of learning in ai
Forms of learning in aiForms of learning in ai
Forms of learning in ai
 
Lt. 5 Pattern Reg.pptx
Lt. 5  Pattern Reg.pptxLt. 5  Pattern Reg.pptx
Lt. 5 Pattern Reg.pptx
 
Handout11
Handout11Handout11
Handout11
 
Machine learning and decision trees
Machine learning and decision treesMachine learning and decision trees
Machine learning and decision trees
 
Statistics for management
Statistics for managementStatistics for management
Statistics for management
 
Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)
Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)
Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)
 
Data mining approaches and methods
Data mining approaches and methodsData mining approaches and methods
Data mining approaches and methods
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_C
 
data
datadata
data
 
Classifiers
ClassifiersClassifiers
Classifiers
 
coppin chapter 10e.ppt
coppin chapter 10e.pptcoppin chapter 10e.ppt
coppin chapter 10e.ppt
 
Machine Learning_PPT.pptx
Machine Learning_PPT.pptxMachine Learning_PPT.pptx
Machine Learning_PPT.pptx
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Decision tree

  • 2. Content  What is decision tree?  Example  How to select the deciding node?  Entropy  Information gain  Gini Impurity  Steps for Making decision tree  Pros.  Cons.
  • 3. What is decision tree?  Decision tree is the most powerful and popular tool for classification and prediction. A Decision tree is a flowchart like tree structure, where each internal node denotes a test on an attribute, each branch represents an outcome of the test, and each leaf node (terminal node) holds a class label.  It is a type of superised learning algorithm.  It is one of the most widely used and practical method for inductive inference
  • 4. Example  Let's assume we want to play badminton on a particular day — say Saturday — how will you decide whether to play or not. Let's say you go out and check if it's hot or cold, check the speed of the wind and humidity, how the weather is, i.e. is it sunny, cloudy, or rainy. You take all these factors into account to decide if you want to play or not.
  • 5. So, you calculate all these factors for the last ten days and form a lookup table like the one below. Day Weather Temperature Humidity Wind 1 Sunny Hot High Weak 2 Cloudy Hot High Weak 3 Sunny Mild Normal Strong 4 Cloudy Mild High Strong 5 Rainy Mild High Strong 6 Rainy Cool Normal Strong 7 Rainy Mild High Weak 8 Sunny Hot High Strong 9 Cloudy Hot Normal Weak 10 Rainy Mild High Strong
  • 6.  A decision tree would be a great way to represent data like this because it takes into account all the possible paths that can lead to the final decision by following a tree-like structure.
  • 7. How to select the deciding node? Which is the best Classifier?
  • 8. So,we can conclude  Less impure node requires less information to describe it.  More impure node requires more information.  Information theory is a measure to define this degree of disorganization in a system known as Entropy.
  • 9. Entropy - measuring homogeneity of a learning set  Entropy is a measure of the uncertainty about a source of messages.  Given a collection S, containing positive and negative examples of some target concept, the entropy of S relative to this classification. where, pi is the proportion of S belonging to class i
  • 10. Entropy is 0 if all the members of S belong to the same class. Entropy is 1 when the collection contains an equal no. of +ve and -ve examples. Entropy is between 0 and 1 if the collection contains unequal no. of +ve and -ve examples.
  • 11. Information gain  Decides which attribute goes into a decision node.  To minimize the decision tree depth, the attribute with the most entropy reduction is the best choice!  They are of 2 types- 1. High Information Gain 2. Low Information Gain
  • 12.  The information gain, Gain(S,A) of an attribute . Where: S is each value v of all possible values of attributeA Sv = subset of S for which attribute A has valuev |Sv| = number of elements in Sv |S| = number of elements in S
  • 13. High Information Gain  An attribute with high information gain splits the data into groups with an uneven number of positives and negatives and as a result helps in separating the two from each other.
  • 14. Low Information Gain  An attribute with low information gain splits the data relatively evenly and as a result doesn’t bring us any closer to a decision.
  • 15. Gini Impurity  Gini Impurity is a measurement of the likelihood of an incorrect classification of a new instance of a random variable, if that new instance were randomly classified according to the distribution of class labels from the data set.  If our dataset is Pure then likelihood of incorrect classification is 0. If our sample is mixture of different classes then likelihood of incorrect classification will be high.  They are of 2 types  Pure means, in a selected sample of dataset all data belongs to same class.  Impure means, data is mixture of different classes.
  • 16. Steps for Making decision tree  Get list of rows (dataset) which are taken into consideration for making decision tree (recursively at each nodes).  Calculate uncertanity of our dataset or Gini impurity or how much our data is mixed up etc.  Generate list of all question which needs to be asked at that node.  Partition rows into True rows and False rows based on each question asked.  Calculate information gain based on gini impurity and partition of data from previous step.  Update highest information gain based on each question asked.  Update best question based on information gain (higher information gain).  Divide the node on best question. Repeat again from step 1 again until we get pure node (leaf
  • 17. Pros.  Easy to use and understand.  Can handle both categorical and numerical data.  Resistant to outliers, hence require little data preprocessing.
  • 18. Cons.  Prone to overfitting.  Require some kind of measurement as to how well they are doing.  Need to be careful with parameter tuning.  Can create biased learned trees if some classes dominate.