SlideShare a Scribd company logo
Decision Trees Learning: ID3
Decision Tree
• Decision tree representation
– Objective
• Classify the instances by sorting them down the tree from
the root to some leaf node, which provides the class of the
instance
– Each node tests the attribute of an instance whereas each branch
descending from that node specifies one possible value of this
attribute
– Testing
• Start at the root node, test the attribute specified by this
node and identify the appropriate branch then repeat the
process
– Example
• Decision tree for classifying the Saturday mornings to test
whether it is suitable for playing outdoor game based on the
weather attributes
For “Yes”
Decision trees represent a
disjunction of conjunctions of
constraints
on the attribute values of
instances.
• The characteristics of best suited problems for DT
– Instances that are represented by attribute-value pairs
• Each attribute takes small number of disjoint possible values (e.g., Hot,
Mild, Cold)  discrete
• Real-valued attributes like temperature  continuous
– The target function has discrete output values
• Binary, multi-class and real-valued outputs
– Disjunctive descriptions may be required
– The training data may contain errors
• DT robust to both errors: errors in classification and attributes
– The training data may contain missing attribute values
• Basics of DT learning - Iterative Dichotomiser 3 - ID3
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
• ID3 algorithm
– ID3 algorithm begins with the original set S as the root node.
– On each iteration of the algorithm, it iterates through every
unused attribute of the set S and calculates the entropy H(S)
(or information gain IG(S)) of that attribute.
– It then selects the attribute which has the smallest entropy (or
largest information gain) value.
• The set S is then split by the selected attribute (e.g. age is less than 50,
age is between 50 and 100, age is greater than 100) to produce subsets
of the data.
– The algorithm continues to recurs on each subset, considering
only attributes never selected before.
• Recursion on a subset may stop, When
– All the elements in the class belong to same class
– All instances does not belong to same class but there is no
attribute to select
– There is no example in the subset
• Steps in ID3
– Calculate the entropy of every attribute using the data set S
– Split the set S into subsets using the attribute for which the
resulting entropy (after splitting) is minimum (or, equivalently,
information gain is maximum)
– Make a decision tree node containing that attribute
– Recurs on subsets using remaining attributes.
• Root - Significance
– Root node
• Which attribute should be tested at the root of the DT?
– Decided based on the information gain or entropy
– Significance
» The best attribute that classifies the training samples very
well
» The attribute that should be tested in all the instances of the
dataset
• @root node
– Information gain is more or entropy has the least value
• Entropy measures the homogeneity or impurities in the
instances
• Information gain measures the expected reduction in
entropy
Decision Trees Learning in Machine Learning
All members are + ve
All members are - ve
Binary or boolean
classification
Multi-class
classification
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
DT by example
Target
Entropy using frequency table of independent attributes on single
dependent attribute
(Target Variable here: PlayGolf)
Decision Trees Learning in Machine Learning
9/14
5/14
Entropy using frequency table of single attribute
on single attribute
Entropy using frequency table of single attribute on dependent attribute
PlayGolf on Outlook
PlayGolf on Temperature
PlayGolf on Humidity
PlayGolf on Windy
Entropy using frequency table of single attribute
on two attribute
= -3/5 log2(3/5) – 2/5 log2(2/5)
=0.971
= -4/4 log2(4/4) – 0/4 log2(0/4)
=0.0
= -2/5 log2(2/5) – 3/5 log2(3/5)
=0.971
Calculation for windy
Calculation for Humidity, Temperature
Gain(PlayGolf , Humidity)=E(PlayGolf)-E(PlayGolf, Humidity)
= 0.94 - P(High) * E(3,4) - P(Normal) * E(6,1)
= 0.940 - 7/14 *E(3,4) - 7/14*E(6,1)
=0.940 – 0.5 * ( 3/7*log(3/7) + 4/7 log(4/7) ) –
0.5* (1/7log(1/7) + 6/7 log(6/7) )
= 0.94 - 0.5 * 0.985 – 0.5 * 0.592 = 0.152
Gain(PlayGolf ,Temperature)=E(PlayGolf)-E(PlayGolf, Temperature)
=0.94 - P(Hot) * E(2,2) - P(Mild) * E(4,2) – P(Cold) E(3,1)
=0.940 - 4/14 *E(2,2) - 6/14*E(4,2) – 4/14 E(3,1)
=0.940 – 4/14 * ( 2/4*log(2/4) + 2/4 log(2/4) ) – 6/14* (4/6log(4/6) + 2/6 log(2/6) ) -
4/14 * ( 3/4*log(3/4) + 1/4 log(1/4) )
= 0.029
Which attribute is the best classifier?
Information gain calculation
WINNER is Outlook and chosen as Root node
Choose attribute with the largest information gain as the
decision node, divide the dataset by its branches and
repeat the same process on every branch.
Decision Trees Learning in Machine Learning
Choose the other nodes below the root
node
Iterate the same procedure for finding
the root node
Refer to slide no 20
P(high)*E(0,3) + P(Normal)*E(2,0)
=3/5*(-0/3 log20/3 – 3/3 log23/3 +
2/5*(-0/2 log20/2 – 2/2 log22/2)
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
Branch with entropy of ‘0’ is a leaf node
Branch with entropy more than ‘0’ needs
further splitting
Decision Trees Learning in Machine Learning
Decision Trees Learning in Machine Learning
Gini index for outlook
Decision Trees Learning in Machine Learning
Gini Gain for all input features
Gini gain (S, outlook) = 0.459 - 0.342 = 0.117
Gini gain(S, Temperature) = 0.459 - 0.4405 = 0.0185
Gini gain(S, Humidity) = 0.459 - 0.3674 = 0.0916
Gini gain(S, windy) = 0.459 - 0.4286 = 0.0304
Choose one that has a higher Gini gain. Gini gain is
higher for outlook. So we can choose it as our root
node.
Gini(S) = 1 - [(9/14)² + (5/14)²] = 0.4591
Try this
Age Income Student Credit_rating Buys_computer
<=30 high no fair no
<=30 high no excellent no
31…40 high no fair yes
>40 medium no fair yes
>40 low yes fair yes
>40 low yes excellent no
31…40 low yes excellent yes
<=30 medium no fair no
<=30 low yes fair yes
>40 medium yes fair yes
<=30 medium yes excellent yes
31…40 medium no excellent yes
31…40 high yes fair yes
>40 medium no excellent no
Output: A Decision Tree for “buys_computer”
age?
overcast
student? credit rating?
no yes fair
excellent
<=30 >40
no no
yes yes
yes
30..40
Pruning Trees
• Remove subtrees for better generalization
(decrease variance)
– Prepruning: Early stopping
– Postpruning: Grow the whole tree then prune subtrees
which overfit on the pruning set
• Prepruning is faster, postpruning is more
accurate (requires a separate pruning set)
Rule Extraction from Trees
C4.5Rules
(Quinlan, 1993)
Learning Rules
• Rule induction is similar to tree induction but
– tree induction is breadth-first,
– rule induction is depth-first; one rule at a time
• Rule set contains rules; rules are conjunctions of terms
• Rule covers an example if all terms of the rule evaluate
to true for the example
• Sequential covering: Generate rules one at a time until
all positive examples are covered
• IREP (Fürnkrantz and Widmer, 1994), Ripper (Cohen,
1995)
Classification and Regression Trees
Comparison between ID3, C4.5 and CART
Decision Tree - Regression
Decision Trees Learning in Machine Learning
• Regression Decision Tree
– The ID3 algorithm can be used to construct a decision tree for
regression by replacing Information Gain with Standard
Deviation Reduction
– If the numerical sample is completely homogeneous its standard
deviation is zero
– Algorithm
• Step 1: The standard deviation of the target is calculated.
• Step 2: The dataset is then split on the different attributes. The standard
deviation for each branch is calculated. The resulting standard deviation
is subtracted from the standard deviation before the split. The result is
the standard deviation reduction.
• Step 3: The attribute with the largest standard deviation reduction is
chosen as the decision node.
• Step 4a: Dataset is divided based on the values of the selected attribute.
• Step 4b: A branch set with standard deviation more than 0 needs further
splitting.
Step.1: Standard deviation for target attribute
Step.2: Standard deviation for two attributes
Step.2: Standard deviation for two attributes
Decision Trees Learning in Machine Learning
Step3
Step 4a
Leaf node?
Decision Trees Learning in Machine Learning
Step 4b
SDR(Sunny, Humidity)=S(Sunny)-S(Sunny, Humidity)
= 10.87 – ( 2/5 (7.5)+ 3/5(12.5))
= 0.37
SDR(Sunny, Temperature)=S(Sunny)-S(Sunny, Temperature)
=10.87 – (3/5(7.3)+2/5(14.5))=2.69
SDR(Sunny, Windy)=S(Sunny)-S(Sunny, Windy) = 10.87 –
(3/5*3.09 +2/5 *3.5) = 7.62
Step 4b
Average of all
instances that
have
outlook=sunny
and windy=false
Decision Trees Learning in Machine Learning
Step 4b
SDR(Rainy, Temperature)=S(Rainy)- S(Rainy, Temperature)
=7.78 – (2/5(2.5)+2/5(6.5)+1/5(0))=4.18
SDR(Rainy, Humidity)= S(Rainy)- S(Rainy, Humidity)
= 7.78 – (3/5(4.08)+ 2/5 (5))
=3.332
SDR(Rainy, Windy)= S(Rainy)- S(Rainy, Windy) = 7.78 – (2/5(9)
+3/5 (5.56)) = 7.78-(3.6+3.336) = 0.844
Hence the RT
Ad

More Related Content

Similar to Decision Trees Learning in Machine Learning (20)

lec02-DecisionTreed. Checking primality of an integer n .pdf
lec02-DecisionTreed. Checking primality of an integer n .pdflec02-DecisionTreed. Checking primality of an integer n .pdf
lec02-DecisionTreed. Checking primality of an integer n .pdf
ahmedghannam12
 
unit 5 decision tree2.pptx
unit 5 decision tree2.pptxunit 5 decision tree2.pptx
unit 5 decision tree2.pptx
ssuser5c580e1
 
ID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC AnalysisID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC Analysis
Talha Kabakus
 
module_3_1.pptx
module_3_1.pptxmodule_3_1.pptx
module_3_1.pptx
Wanderer20
 
module_3_1.pptx
module_3_1.pptxmodule_3_1.pptx
module_3_1.pptx
Wanderer20
 
Lect9 Decision tree
Lect9 Decision treeLect9 Decision tree
Lect9 Decision tree
hktripathy
 
CS632_Lecture_15_updated.pptx
CS632_Lecture_15_updated.pptxCS632_Lecture_15_updated.pptx
CS632_Lecture_15_updated.pptx
MuhammadAbubakar114879
 
Machine Learning with Python unit-2.pptx
Machine Learning with Python unit-2.pptxMachine Learning with Python unit-2.pptx
Machine Learning with Python unit-2.pptx
GORANG6
 
Decision Tree.pptx
Decision Tree.pptxDecision Tree.pptx
Decision Tree.pptx
JayabharathiMuraliku
 
Decision tree
Decision treeDecision tree
Decision tree
Tilani Gunawardena PhD(UNIBAS), BSc(Pera), FHEA(UK), CEng, MIESL
 
Decision Tree Learning: Decision tree representation, Appropriate problems fo...
Decision Tree Learning: Decision tree representation, Appropriate problems fo...Decision Tree Learning: Decision tree representation, Appropriate problems fo...
Decision Tree Learning: Decision tree representation, Appropriate problems fo...
BMS Institute of Technology and Management
 
Decision Trees - The Machine Learning Magic Unveiled
Decision Trees - The Machine Learning Magic UnveiledDecision Trees - The Machine Learning Magic Unveiled
Decision Trees - The Machine Learning Magic Unveiled
Luca Zavarella
 
Machine Learning, Decision Tree Learning module_2_ppt.pptx
Machine Learning, Decision Tree Learning module_2_ppt.pptxMachine Learning, Decision Tree Learning module_2_ppt.pptx
Machine Learning, Decision Tree Learning module_2_ppt.pptx
radhikakalyankumar
 
Chapter 4.pdf
Chapter 4.pdfChapter 4.pdf
Chapter 4.pdf
DrGnaneswariG
 
Descision making descision making decision tree.pptx
Descision making descision making decision tree.pptxDescision making descision making decision tree.pptx
Descision making descision making decision tree.pptx
charmeshponnagani
 
Decision Trees
Decision TreesDecision Trees
Decision Trees
zekeLabs Technologies
 
2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx
2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx
2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx
Pluto62
 
Decision tree for data mining and computer
Decision tree for data mining and computerDecision tree for data mining and computer
Decision tree for data mining and computer
tttiba
 
decision tree and random forest in AIML for CSE
decision tree and random forest in AIML for CSEdecision tree and random forest in AIML for CSE
decision tree and random forest in AIML for CSE
premkumar1891
 
Decision tree and random forest
Decision tree and random forestDecision tree and random forest
Decision tree and random forest
Lippo Group Digital
 
lec02-DecisionTreed. Checking primality of an integer n .pdf
lec02-DecisionTreed. Checking primality of an integer n .pdflec02-DecisionTreed. Checking primality of an integer n .pdf
lec02-DecisionTreed. Checking primality of an integer n .pdf
ahmedghannam12
 
unit 5 decision tree2.pptx
unit 5 decision tree2.pptxunit 5 decision tree2.pptx
unit 5 decision tree2.pptx
ssuser5c580e1
 
ID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC AnalysisID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC Analysis
Talha Kabakus
 
module_3_1.pptx
module_3_1.pptxmodule_3_1.pptx
module_3_1.pptx
Wanderer20
 
module_3_1.pptx
module_3_1.pptxmodule_3_1.pptx
module_3_1.pptx
Wanderer20
 
Lect9 Decision tree
Lect9 Decision treeLect9 Decision tree
Lect9 Decision tree
hktripathy
 
Machine Learning with Python unit-2.pptx
Machine Learning with Python unit-2.pptxMachine Learning with Python unit-2.pptx
Machine Learning with Python unit-2.pptx
GORANG6
 
Decision Tree Learning: Decision tree representation, Appropriate problems fo...
Decision Tree Learning: Decision tree representation, Appropriate problems fo...Decision Tree Learning: Decision tree representation, Appropriate problems fo...
Decision Tree Learning: Decision tree representation, Appropriate problems fo...
BMS Institute of Technology and Management
 
Decision Trees - The Machine Learning Magic Unveiled
Decision Trees - The Machine Learning Magic UnveiledDecision Trees - The Machine Learning Magic Unveiled
Decision Trees - The Machine Learning Magic Unveiled
Luca Zavarella
 
Machine Learning, Decision Tree Learning module_2_ppt.pptx
Machine Learning, Decision Tree Learning module_2_ppt.pptxMachine Learning, Decision Tree Learning module_2_ppt.pptx
Machine Learning, Decision Tree Learning module_2_ppt.pptx
radhikakalyankumar
 
Descision making descision making decision tree.pptx
Descision making descision making decision tree.pptxDescision making descision making decision tree.pptx
Descision making descision making decision tree.pptx
charmeshponnagani
 
2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx
2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx
2c-decisfffffffffffffffffffffffion-tree-algorithm.pptx
Pluto62
 
Decision tree for data mining and computer
Decision tree for data mining and computerDecision tree for data mining and computer
Decision tree for data mining and computer
tttiba
 
decision tree and random forest in AIML for CSE
decision tree and random forest in AIML for CSEdecision tree and random forest in AIML for CSE
decision tree and random forest in AIML for CSE
premkumar1891
 

More from Senthil Vit (20)

Logical Design Architecture in Internet of Things
Logical Design Architecture in Internet of ThingsLogical Design Architecture in Internet of Things
Logical Design Architecture in Internet of Things
Senthil Vit
 
Wireless sensor networks in Internet of Things
Wireless sensor networks in Internet of ThingsWireless sensor networks in Internet of Things
Wireless sensor networks in Internet of Things
Senthil Vit
 
Classification Algorithm in Machine Learning
Classification Algorithm in Machine LearningClassification Algorithm in Machine Learning
Classification Algorithm in Machine Learning
Senthil Vit
 
Operating system Virtualization_NEW.pptx
Operating system Virtualization_NEW.pptxOperating system Virtualization_NEW.pptx
Operating system Virtualization_NEW.pptx
Senthil Vit
 
Synchronization Peterson’s Solution.pptx
Synchronization Peterson’s Solution.pptxSynchronization Peterson’s Solution.pptx
Synchronization Peterson’s Solution.pptx
Senthil Vit
 
Control structures in Python programming
Control structures in Python programmingControl structures in Python programming
Control structures in Python programming
Senthil Vit
 
Data and Expressions in Python programming
Data and Expressions in Python programmingData and Expressions in Python programming
Data and Expressions in Python programming
Senthil Vit
 
Python programming Introduction about Python
Python programming Introduction about PythonPython programming Introduction about Python
Python programming Introduction about Python
Senthil Vit
 
Switching Problems.pdf
Switching Problems.pdfSwitching Problems.pdf
Switching Problems.pdf
Senthil Vit
 
Big Oh.ppt
Big Oh.pptBig Oh.ppt
Big Oh.ppt
Senthil Vit
 
AsymptoticNotations.ppt
AsymptoticNotations.pptAsymptoticNotations.ppt
AsymptoticNotations.ppt
Senthil Vit
 
snort.ppt
snort.pptsnort.ppt
snort.ppt
Senthil Vit
 
First Best and Worst Fit.pptx
First Best and Worst Fit.pptxFirst Best and Worst Fit.pptx
First Best and Worst Fit.pptx
Senthil Vit
 
File Implementation Problem.pptx
File Implementation Problem.pptxFile Implementation Problem.pptx
File Implementation Problem.pptx
Senthil Vit
 
Design Issues of an OS.ppt
Design Issues of an OS.pptDesign Issues of an OS.ppt
Design Issues of an OS.ppt
Senthil Vit
 
Operating Systems – Structuring Methods.pptx
Operating Systems – Structuring Methods.pptxOperating Systems – Structuring Methods.pptx
Operating Systems – Structuring Methods.pptx
Senthil Vit
 
deadlock.ppt
deadlock.pptdeadlock.ppt
deadlock.ppt
Senthil Vit
 
Virtualization.pptx
Virtualization.pptxVirtualization.pptx
Virtualization.pptx
Senthil Vit
 
Traffic-Monitoring.ppt
Traffic-Monitoring.pptTraffic-Monitoring.ppt
Traffic-Monitoring.ppt
Senthil Vit
 
Lect_2.pptx
Lect_2.pptxLect_2.pptx
Lect_2.pptx
Senthil Vit
 
Logical Design Architecture in Internet of Things
Logical Design Architecture in Internet of ThingsLogical Design Architecture in Internet of Things
Logical Design Architecture in Internet of Things
Senthil Vit
 
Wireless sensor networks in Internet of Things
Wireless sensor networks in Internet of ThingsWireless sensor networks in Internet of Things
Wireless sensor networks in Internet of Things
Senthil Vit
 
Classification Algorithm in Machine Learning
Classification Algorithm in Machine LearningClassification Algorithm in Machine Learning
Classification Algorithm in Machine Learning
Senthil Vit
 
Operating system Virtualization_NEW.pptx
Operating system Virtualization_NEW.pptxOperating system Virtualization_NEW.pptx
Operating system Virtualization_NEW.pptx
Senthil Vit
 
Synchronization Peterson’s Solution.pptx
Synchronization Peterson’s Solution.pptxSynchronization Peterson’s Solution.pptx
Synchronization Peterson’s Solution.pptx
Senthil Vit
 
Control structures in Python programming
Control structures in Python programmingControl structures in Python programming
Control structures in Python programming
Senthil Vit
 
Data and Expressions in Python programming
Data and Expressions in Python programmingData and Expressions in Python programming
Data and Expressions in Python programming
Senthil Vit
 
Python programming Introduction about Python
Python programming Introduction about PythonPython programming Introduction about Python
Python programming Introduction about Python
Senthil Vit
 
Switching Problems.pdf
Switching Problems.pdfSwitching Problems.pdf
Switching Problems.pdf
Senthil Vit
 
AsymptoticNotations.ppt
AsymptoticNotations.pptAsymptoticNotations.ppt
AsymptoticNotations.ppt
Senthil Vit
 
First Best and Worst Fit.pptx
First Best and Worst Fit.pptxFirst Best and Worst Fit.pptx
First Best and Worst Fit.pptx
Senthil Vit
 
File Implementation Problem.pptx
File Implementation Problem.pptxFile Implementation Problem.pptx
File Implementation Problem.pptx
Senthil Vit
 
Design Issues of an OS.ppt
Design Issues of an OS.pptDesign Issues of an OS.ppt
Design Issues of an OS.ppt
Senthil Vit
 
Operating Systems – Structuring Methods.pptx
Operating Systems – Structuring Methods.pptxOperating Systems – Structuring Methods.pptx
Operating Systems – Structuring Methods.pptx
Senthil Vit
 
Virtualization.pptx
Virtualization.pptxVirtualization.pptx
Virtualization.pptx
Senthil Vit
 
Traffic-Monitoring.ppt
Traffic-Monitoring.pptTraffic-Monitoring.ppt
Traffic-Monitoring.ppt
Senthil Vit
 
Ad

Recently uploaded (20)

May 2025 - Top 10 Read Articles in Network Security and Its Applications
May 2025 - Top 10 Read Articles in Network Security and Its ApplicationsMay 2025 - Top 10 Read Articles in Network Security and Its Applications
May 2025 - Top 10 Read Articles in Network Security and Its Applications
IJNSA Journal
 
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks Conferences
 
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
Journal of Soft Computing in Civil Engineering
 
Jeff Menashe - A Dedicated Senior Software Engineer
Jeff Menashe - A Dedicated Senior Software EngineerJeff Menashe - A Dedicated Senior Software Engineer
Jeff Menashe - A Dedicated Senior Software Engineer
Jeff Menashe
 
Concept Learning - Find S Algorithm,Candidate Elimination Algorithm
Concept Learning - Find S Algorithm,Candidate Elimination AlgorithmConcept Learning - Find S Algorithm,Candidate Elimination Algorithm
Concept Learning - Find S Algorithm,Candidate Elimination Algorithm
Global Academy of Technology
 
DeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFTDeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFT
Kyohei Ito
 
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
 
VISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated detailsVISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated details
Vishal Kumar Singh
 
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
54mdaadil
 
Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)
efs14135
 
digital computing plotform synopsis.pptx
digital computing plotform synopsis.pptxdigital computing plotform synopsis.pptx
digital computing plotform synopsis.pptx
ssuser2b4c6e1
 
Dr. Shivu___Machine Learning_Module 2pdf
Dr. Shivu___Machine Learning_Module 2pdfDr. Shivu___Machine Learning_Module 2pdf
Dr. Shivu___Machine Learning_Module 2pdf
Dr. Shivashankar
 
Evaluating Adaptive Neuro-Fuzzy Inference System (ANFIS) To Assess Liquefacti...
Evaluating Adaptive Neuro-Fuzzy Inference System (ANFIS) To Assess Liquefacti...Evaluating Adaptive Neuro-Fuzzy Inference System (ANFIS) To Assess Liquefacti...
Evaluating Adaptive Neuro-Fuzzy Inference System (ANFIS) To Assess Liquefacti...
Journal of Soft Computing in Civil Engineering
 
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...
ijfcstjournal
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
MS Project - Pelaksanaan Proyek Fisik 2020
MS Project - Pelaksanaan Proyek Fisik 2020MS Project - Pelaksanaan Proyek Fisik 2020
MS Project - Pelaksanaan Proyek Fisik 2020
Bagus ardian
 
Dr. Shivu__Machine Learning-Module 3.pdf
Dr. Shivu__Machine Learning-Module 3.pdfDr. Shivu__Machine Learning-Module 3.pdf
Dr. Shivu__Machine Learning-Module 3.pdf
Dr. Shivashankar
 
Engr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdf
Engr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdfEngr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdf
Engr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdf
JOEL B. YOSORES
 
A Detailed Guide on Piping Isometric Drawings
A Detailed Guide on Piping Isometric DrawingsA Detailed Guide on Piping Isometric Drawings
A Detailed Guide on Piping Isometric Drawings
Tesla CAD Solutions
 
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
Jimmy Lai
 
May 2025 - Top 10 Read Articles in Network Security and Its Applications
May 2025 - Top 10 Read Articles in Network Security and Its ApplicationsMay 2025 - Top 10 Read Articles in Network Security and Its Applications
May 2025 - Top 10 Read Articles in Network Security and Its Applications
IJNSA Journal
 
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks Conferences
 
Jeff Menashe - A Dedicated Senior Software Engineer
Jeff Menashe - A Dedicated Senior Software EngineerJeff Menashe - A Dedicated Senior Software Engineer
Jeff Menashe - A Dedicated Senior Software Engineer
Jeff Menashe
 
Concept Learning - Find S Algorithm,Candidate Elimination Algorithm
Concept Learning - Find S Algorithm,Candidate Elimination AlgorithmConcept Learning - Find S Algorithm,Candidate Elimination Algorithm
Concept Learning - Find S Algorithm,Candidate Elimination Algorithm
Global Academy of Technology
 
DeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFTDeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | 🤖Mint to DeFAI. Vibe Trading as NFT
Kyohei Ito
 
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
 
VISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated detailsVISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated details
Vishal Kumar Singh
 
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
54mdaadil
 
Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)
efs14135
 
digital computing plotform synopsis.pptx
digital computing plotform synopsis.pptxdigital computing plotform synopsis.pptx
digital computing plotform synopsis.pptx
ssuser2b4c6e1
 
Dr. Shivu___Machine Learning_Module 2pdf
Dr. Shivu___Machine Learning_Module 2pdfDr. Shivu___Machine Learning_Module 2pdf
Dr. Shivu___Machine Learning_Module 2pdf
Dr. Shivashankar
 
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...
ijfcstjournal
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
MS Project - Pelaksanaan Proyek Fisik 2020
MS Project - Pelaksanaan Proyek Fisik 2020MS Project - Pelaksanaan Proyek Fisik 2020
MS Project - Pelaksanaan Proyek Fisik 2020
Bagus ardian
 
Dr. Shivu__Machine Learning-Module 3.pdf
Dr. Shivu__Machine Learning-Module 3.pdfDr. Shivu__Machine Learning-Module 3.pdf
Dr. Shivu__Machine Learning-Module 3.pdf
Dr. Shivashankar
 
Engr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdf
Engr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdfEngr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdf
Engr. Joel B. Yosores_RMEE_RMP_PMP_MBA.pdf
JOEL B. YOSORES
 
A Detailed Guide on Piping Isometric Drawings
A Detailed Guide on Piping Isometric DrawingsA Detailed Guide on Piping Isometric Drawings
A Detailed Guide on Piping Isometric Drawings
Tesla CAD Solutions
 
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
Jimmy Lai
 
Ad

Decision Trees Learning in Machine Learning

  • 3. • Decision tree representation – Objective • Classify the instances by sorting them down the tree from the root to some leaf node, which provides the class of the instance – Each node tests the attribute of an instance whereas each branch descending from that node specifies one possible value of this attribute – Testing • Start at the root node, test the attribute specified by this node and identify the appropriate branch then repeat the process – Example • Decision tree for classifying the Saturday mornings to test whether it is suitable for playing outdoor game based on the weather attributes
  • 4. For “Yes” Decision trees represent a disjunction of conjunctions of constraints on the attribute values of instances.
  • 5. • The characteristics of best suited problems for DT – Instances that are represented by attribute-value pairs • Each attribute takes small number of disjoint possible values (e.g., Hot, Mild, Cold)  discrete • Real-valued attributes like temperature  continuous – The target function has discrete output values • Binary, multi-class and real-valued outputs – Disjunctive descriptions may be required – The training data may contain errors • DT robust to both errors: errors in classification and attributes – The training data may contain missing attribute values
  • 6. • Basics of DT learning - Iterative Dichotomiser 3 - ID3
  • 9. • ID3 algorithm – ID3 algorithm begins with the original set S as the root node. – On each iteration of the algorithm, it iterates through every unused attribute of the set S and calculates the entropy H(S) (or information gain IG(S)) of that attribute. – It then selects the attribute which has the smallest entropy (or largest information gain) value. • The set S is then split by the selected attribute (e.g. age is less than 50, age is between 50 and 100, age is greater than 100) to produce subsets of the data. – The algorithm continues to recurs on each subset, considering only attributes never selected before.
  • 10. • Recursion on a subset may stop, When – All the elements in the class belong to same class – All instances does not belong to same class but there is no attribute to select – There is no example in the subset • Steps in ID3 – Calculate the entropy of every attribute using the data set S – Split the set S into subsets using the attribute for which the resulting entropy (after splitting) is minimum (or, equivalently, information gain is maximum) – Make a decision tree node containing that attribute – Recurs on subsets using remaining attributes.
  • 11. • Root - Significance – Root node • Which attribute should be tested at the root of the DT? – Decided based on the information gain or entropy – Significance » The best attribute that classifies the training samples very well » The attribute that should be tested in all the instances of the dataset • @root node – Information gain is more or entropy has the least value • Entropy measures the homogeneity or impurities in the instances • Information gain measures the expected reduction in entropy
  • 13. All members are + ve All members are - ve Binary or boolean classification Multi-class classification
  • 18. Entropy using frequency table of independent attributes on single dependent attribute (Target Variable here: PlayGolf)
  • 20. 9/14 5/14 Entropy using frequency table of single attribute on single attribute
  • 21. Entropy using frequency table of single attribute on dependent attribute PlayGolf on Outlook PlayGolf on Temperature PlayGolf on Humidity PlayGolf on Windy
  • 22. Entropy using frequency table of single attribute on two attribute = -3/5 log2(3/5) – 2/5 log2(2/5) =0.971 = -4/4 log2(4/4) – 0/4 log2(0/4) =0.0 = -2/5 log2(2/5) – 3/5 log2(3/5) =0.971
  • 24. Calculation for Humidity, Temperature Gain(PlayGolf , Humidity)=E(PlayGolf)-E(PlayGolf, Humidity) = 0.94 - P(High) * E(3,4) - P(Normal) * E(6,1) = 0.940 - 7/14 *E(3,4) - 7/14*E(6,1) =0.940 – 0.5 * ( 3/7*log(3/7) + 4/7 log(4/7) ) – 0.5* (1/7log(1/7) + 6/7 log(6/7) ) = 0.94 - 0.5 * 0.985 – 0.5 * 0.592 = 0.152 Gain(PlayGolf ,Temperature)=E(PlayGolf)-E(PlayGolf, Temperature) =0.94 - P(Hot) * E(2,2) - P(Mild) * E(4,2) – P(Cold) E(3,1) =0.940 - 4/14 *E(2,2) - 6/14*E(4,2) – 4/14 E(3,1) =0.940 – 4/14 * ( 2/4*log(2/4) + 2/4 log(2/4) ) – 6/14* (4/6log(4/6) + 2/6 log(2/6) ) - 4/14 * ( 3/4*log(3/4) + 1/4 log(1/4) ) = 0.029
  • 25. Which attribute is the best classifier?
  • 27. WINNER is Outlook and chosen as Root node Choose attribute with the largest information gain as the decision node, divide the dataset by its branches and repeat the same process on every branch.
  • 29. Choose the other nodes below the root node Iterate the same procedure for finding the root node
  • 30. Refer to slide no 20 P(high)*E(0,3) + P(Normal)*E(2,0) =3/5*(-0/3 log20/3 – 3/3 log23/3 + 2/5*(-0/2 log20/2 – 2/2 log22/2)
  • 36. Branch with entropy of ‘0’ is a leaf node
  • 37. Branch with entropy more than ‘0’ needs further splitting
  • 40. Gini index for outlook
  • 42. Gini Gain for all input features Gini gain (S, outlook) = 0.459 - 0.342 = 0.117 Gini gain(S, Temperature) = 0.459 - 0.4405 = 0.0185 Gini gain(S, Humidity) = 0.459 - 0.3674 = 0.0916 Gini gain(S, windy) = 0.459 - 0.4286 = 0.0304 Choose one that has a higher Gini gain. Gini gain is higher for outlook. So we can choose it as our root node. Gini(S) = 1 - [(9/14)² + (5/14)²] = 0.4591
  • 43. Try this Age Income Student Credit_rating Buys_computer <=30 high no fair no <=30 high no excellent no 31…40 high no fair yes >40 medium no fair yes >40 low yes fair yes >40 low yes excellent no 31…40 low yes excellent yes <=30 medium no fair no <=30 low yes fair yes >40 medium yes fair yes <=30 medium yes excellent yes 31…40 medium no excellent yes 31…40 high yes fair yes >40 medium no excellent no
  • 44. Output: A Decision Tree for “buys_computer” age? overcast student? credit rating? no yes fair excellent <=30 >40 no no yes yes yes 30..40
  • 45. Pruning Trees • Remove subtrees for better generalization (decrease variance) – Prepruning: Early stopping – Postpruning: Grow the whole tree then prune subtrees which overfit on the pruning set • Prepruning is faster, postpruning is more accurate (requires a separate pruning set)
  • 46. Rule Extraction from Trees C4.5Rules (Quinlan, 1993)
  • 47. Learning Rules • Rule induction is similar to tree induction but – tree induction is breadth-first, – rule induction is depth-first; one rule at a time • Rule set contains rules; rules are conjunctions of terms • Rule covers an example if all terms of the rule evaluate to true for the example • Sequential covering: Generate rules one at a time until all positive examples are covered • IREP (Fürnkrantz and Widmer, 1994), Ripper (Cohen, 1995)
  • 49. Comparison between ID3, C4.5 and CART
  • 50. Decision Tree - Regression
  • 52. • Regression Decision Tree – The ID3 algorithm can be used to construct a decision tree for regression by replacing Information Gain with Standard Deviation Reduction – If the numerical sample is completely homogeneous its standard deviation is zero – Algorithm • Step 1: The standard deviation of the target is calculated. • Step 2: The dataset is then split on the different attributes. The standard deviation for each branch is calculated. The resulting standard deviation is subtracted from the standard deviation before the split. The result is the standard deviation reduction. • Step 3: The attribute with the largest standard deviation reduction is chosen as the decision node. • Step 4a: Dataset is divided based on the values of the selected attribute. • Step 4b: A branch set with standard deviation more than 0 needs further splitting.
  • 53. Step.1: Standard deviation for target attribute
  • 54. Step.2: Standard deviation for two attributes
  • 55. Step.2: Standard deviation for two attributes
  • 57. Step3
  • 61. Step 4b SDR(Sunny, Humidity)=S(Sunny)-S(Sunny, Humidity) = 10.87 – ( 2/5 (7.5)+ 3/5(12.5)) = 0.37 SDR(Sunny, Temperature)=S(Sunny)-S(Sunny, Temperature) =10.87 – (3/5(7.3)+2/5(14.5))=2.69 SDR(Sunny, Windy)=S(Sunny)-S(Sunny, Windy) = 10.87 – (3/5*3.09 +2/5 *3.5) = 7.62
  • 62. Step 4b Average of all instances that have outlook=sunny and windy=false
  • 64. Step 4b SDR(Rainy, Temperature)=S(Rainy)- S(Rainy, Temperature) =7.78 – (2/5(2.5)+2/5(6.5)+1/5(0))=4.18 SDR(Rainy, Humidity)= S(Rainy)- S(Rainy, Humidity) = 7.78 – (3/5(4.08)+ 2/5 (5)) =3.332 SDR(Rainy, Windy)= S(Rainy)- S(Rainy, Windy) = 7.78 – (2/5(9) +3/5 (5.56)) = 7.78-(3.6+3.336) = 0.844
  翻译: