Datamining
Datamining
Decision Tree
Name: Hafiz Muhammad Behzad
Roll no: 17271519-027
-------------------------------------------------------------------------------------------------------------------------------
Q1. Create a decision tree using Information Gain, Gain Ratio and Gini Index of the following
data set. Also define the Rules Set of each decision tree.
Information Gain:
1. Calculate entropy of the target
1
Gain (Student, Buys_computer) = Entropy (Buys_computer) - Entropy (Student,
Buys_computer)
Selected Age as root node with Childs <=30 , 31-40 -> buy=yes , >40 or 30 .
2
= 0.97 – 0 = 0.97
= 0.95
= 3/5 * 0 + 2/5 * 0 = 0
3
Gain (Credit_rating, Buys_computer) = Entropy (Buys_computer) - Entropy (Credit_rating,
Buys_computer)
= 0.97 – 0 = 0.97
Rules set:
Gain Ration:
1. Calculate the gain ratio of the each attribute:
= 1.56
= 0.99
4
1. Calculate the gain ratio of the each attribute:
SplitInfo_student (yes,no) = B
5
Gain (Student, Buys_computer) = Entropy (Buys_computer) - Entropy (Student,
Buys_computer)
Credit_rating
Fair Excellent
Student student
Yes No yes no