Decision Trees data analytics and data ensemble methods
vaishalibagewadikar1
8 views
47 slides
Nov 02, 2025
Slide 1 of 47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
About This Presentation
decision trees on data progression
Size: 832.47 KB
Language: en
Added: Nov 02, 2025
Slides: 47 pages
Slide Content
Presented by Gayathri Hegde Research Scholar Dept of CSE, UVCE Under Guidance Dr P Deepa Shenoy Dean, Professor, Dept of CSE, UVCE Bangalore
CAR Price >10L Price >10L Decline Bad Mileage Decline Good Mileage Safety Decline Less Safety Color Red Blue Decline Buy
Decision Trees Is a simple but powerful learning paradigm. It’s a type of classification algorithm for supervised algorithm . Is a graphical representation of a tree-shaped diagram that is used to determine the course of action. Each branch node represents a choice between number of alternatives and each leaf node represents a decision. Each node represents a feature (attribute). Each link(Branch) represents a Decision (Rule). Each leaf represents an outcome (Categorical or continuous).
Important terminologies used in Decision Trees Root Node: Topmost node in the decision tree where all the information is stored or has the highest entropy. Decision Node has 2 or more branches . It’s the mid node in the decision tree where 2 or more splits arise. Leaf Node : It’s the end of the decision tree that carries the classification or the decision information
Important terminologies used in Decision Trees Entropy: is measure of amount of uncertainty in the dataset S. Average Information Entropy Entropy(Attribute) Information Gain: Tells us how much uncertainty was reduced after splitting datasets in attribute. Information Gain=Entropy(S)- I(Attribute)
ID3(Iterative Dichotomiser 3) algorithm iteratively ( repeatedly ) dichotomizes( divides ) features into two or more groups at each step . It’s a classification algorithm Follows greedy approach by selecting a best attribute that yields maximum Information Gain(IG) or minimum Entropy.
Steps to construct the Decision Tree Compute Entropy for dataset – Entropy(S) For Every attribute/Features Calculate entropy for all other values - Entropy(A). Take average information entropy for the current attribute. Calculate Gain for the current attribute . Pick the highest gain attribute. Repeat until we get the desired tree.
Decision Tree for the dataset Sl No Outlook Temperature Humidity Windy Play Tennis 1 Sunny Hot High Weak No 2 Sunny Hot High Strong No 3 Overcast Hot High Weak Yes 4 Rainy Mild High Weak Yes 5 Rainy Cool Normal Weak Yes 6 Rainy Cool Normal Strong No 7 Overcast Cool Normal Strong Yes 8 Sunny Mild High Weak No 9 Sunny Cool Normal Weak Yes 10 Rainy Mild Normal Weak Yes 11 Sunny Mild Normal Strong Yes 12 Overcast Mild High Strong Yes 13 Overcast Hot Normal Weak Yes 14 Rainy Mild High Strong No
Step1:Calculate the Entropy(S) No. of + ve attribute P=9 – ve attribute is N=5 Total:14 = 0.940 (Entropy of the entire dataset)
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Outlook Outlook P N Entropy Sunny 2 3 Rainy 3 2 Overcast 4 = Outlook P N Entropy Sunny 2 3 0.971 Rainy 3 2 0.971 Overcast 4
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) 0.693
Step2.3: Calculate Information Gain- Attribute Outlook Information Gain=Entropy(S)-I(Attribute=Outlook) = 0.940-0.693 = 0.247 Attribute Information Gain Outlook 0.247 Temperature Humidity Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Temperature = 0.811 Temperature P N Entropy Hot 2 2 Mild 4 2 Cool 3 1 Temperature P N Entropy Hot 2 2 1 Mild 4 2 0.918 Cool 3 1 0.811
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) 0. 9 11
Step2.3: Calculate Information Gain- Attribute Temperature Information Gain=Entropy(S)-I(Attribute=Temperature) = 0.940-0.911 =0.029 Attribute Information Gain Outlook 0.247 Temperature 0.029 Humidity Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Humidity Humidity P N Entropy High 3 4 Normal 6 1 Humidity P N Entropy High 3 4 0.985 Normal 6 1 0.591
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) 0.788
Step2.3: Calculate Information Gain- Attribute Humidity Information Gain=Entropy(S)-I(Attribute=Humidity) = 0.940-0.788 =0.152 Attribute Information Gain Outlook 0.247 Temperature 0.029 Humidity 0.152 Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Windy Windy P N Entropy Strong 3 3 Weak 6 2 Windy P N Entropy Strong 3 3 1 Weak 6 2 0.811
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) 0.892
Step2.3: Calculate Information Gain- Attribute Humidity Information Gain=Entropy(S)-I(Attribute=Humidity) = 0.940-0.892 =0.048 Attribute Information Gain Outlook 0.247 Temperature 0.029 Humidity 0.152 Windy 0.048
Step 3:Pick the highest Gain attribute Here the attribute with maximum Information Gain is outlook Hence RootNode will be outlook. Repeat step 1 to 3 again for Sunny and Rainy. Attribute Information Gain Outlook 0.247 Temperature 0.029 Humidity 0.152 Windy 0.048 Outlook ? ? Yes Overcast Sunny Rainy
New dataset to be considered - Sunny Sl No Outlook Temperature Humidity Windy Play Tennis 1 Sunny Hot High Weak No 2 Sunny Hot High Strong No 8 Sunny Mild High Weak No 9 Sunny Cool Normal Weak Yes 11 Sunny Mild Normal Strong Yes Step1:Calculate the Entropy(S) No. of + ve attribute P=2 and – ve attribute is N=3 Total: 5 = 0.971 (Entropy of the entire dataset)
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Temperature Temperature P N Entropy Hot 1 Mild 2 Cool 1 1 1 Sl No Outlook Temperature Humidity Windy Play Tennis 1 Sunny Hot High Weak No 2 Sunny Hot High Strong No 8 Sunny Mild High Weak No 9 Sunny Cool Normal Weak Yes 11 Sunny Mild Normal Strong Yes
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) . 4
Step2.3: Calculate Information Gain- Attribute Temperature Information Gain=Entropy(S)-I(Attribute=Temperature) = 0.971-0.4 = 0.571 Attribute Information Gain Temperature 0.571 Humidity Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Humidity Humidity P N Entropy High 3 Normal 2
Step 2.2 Calculate the average Information Entropy Entropy(Attribute)
Step2.3: Calculate Information Gain- Attribute Humidity Information Gain=Entropy(S)-I(Attribute=Humidity) = 0.971-0 = 0.971 Attribute Information Gain Temperature 0.571 Humidity 0.971 Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Windy Windy P N Entropy Strong 1 1 Weak 1 2 Windy P N Entropy Strong 1 1 1 Weak 1 2 0.918
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) 0.951
Step2.3: Calculate Information Gain- Attribute Humidity Information Gain=Entropy(S)-I(Attribute=Humidity) = 0.971-0.951 =0.020 Attribute Information Gain Temperature 0.571 Humidity 0.971 Windy 0.02
Step 3:Pick the highest Gain attribute Here the attribute with maximum Information Gain is Humidity. Repeat step 1 to 3 again for Sunny and Rainy. Outlook ? Humidity Yes Normal Sunny Rainy Attribute Information Gain Temperature 0.571 Humidity 0.971 Windy 0.02 Yes No Overcast High
New dataset to be considered - Rainy Sl No Outlook Temperature Humidity Windy Play Tennis 4 Rainy Mild High Weak Yes 5 Rainy Cool Normal Weak Yes 6 Rainy Cool Normal Strong No 10 Rainy Mild Normal Weak Yes 14 Rainy Mild High Strong No Step1:Calculate the Entropy(S) No. of + ve attribute P=3 and – ve attribute is N=2 Total: 5 = 0.971(Entropy of the entire dataset)
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Temperature Temperature P N Entropy Mild 2 1 Cool 1 1 Temperature P N Entropy Mild 2 1 0.918 Cool 1 1 1
Step 2.2 Calculate the average Information Entropy Entropy(Attribute)
Step2.3: Calculate Information Gain- Attribute Temperature Information Gain=Entropy(S)-I(Attribute=Temperature) = 0.971-0.951 =0.020 Attribute Information Gain Temperature 0.020 Humidity Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Humidity Humidity P N Entropy High 1 1 1 Normal 2 1 0.918
Step 2.2 Calculate the average Information Entropy Entropy(Attribute) 0.951
Step2.3: Calculate Information Gain- Attribute Humidity Information Gain=Entropy(S)-I(Attribute=Humidity) = 0.971-0.951 =0.020 Attribute Information Gain Temperature 0.020 Humidity 0.020 Windy
Step2.1: For each attribute –calculate Entropy for each values- Attribute - Windy Windy P N Entropy Strong 2 Weak 3
Step 2.2 Calculate the average Information Entropy Entropy(Attribute)
Step2.3: Calculate Information Gain- Attribute Humidity Information Gain=Entropy(S)-I(Attribute=Humidity) = 0.971-0 =0.971 Attribute Information Gain Temperature 0.020 Humidity 0.020 Windy 0.971
Step 3:Pick the highest Gain attribute Here the attribute with maximum Information Gain is Windy. Repeat step 1 to 3 again for Sunny and Rainy. Outlook Windy Humidity Yes Normal Sunny Rainy Yes No Overcast High Attribute Information Gain Temperature 0.020 Humidity 0.020 Windy 0.971 Weak Yes No Strong Final Decision Tree
Advantages and Disadvantages simple to understand and interpret . Little effort in data preparation. Non-linear parameter does not effect performance. Disadvantages Overfitting: In case of noise in the data. Instability: Models can become unstable due to variations in data.