Professional Documents
Culture Documents
A decision tree represents a function that takes a vector of attribute values as inputs and returns a
‘decision’ – a single output value.
Ex: Let us take a decision to go out for playing depending on weather condition. The decision tree is
given below:
Which attribute should be taken as root node? This question is answered based on values of 1)
entropy and 2) gini index.
Both the entropy and gini index represent impurity level in the dataset.
ENTROPY
Entropy is the measure of randomness of data. When the data is more random, it means, there are
impurities. When entropy is less, the data is good. When entropy is less ‘information gain’ in every
split will be more.
Entropy is useful to decide which attribute is to be selected as root node in the decision tree.
Suppose, we take outlook as root node, then the following decision tree arises.
So, Entropy (outlook=Sunny) = -2/5 log2 2/5 - 3/5 log2 3/5 = 0.971
This gain must be high. That node is to be selected as root node. Similarly
repeat for other nodes (like Temperature, Humidity, and Windy).
GINI INDEX
overcast = 4 Yes, 0 No
rainy = 3 Yes, 2 No
In the same manner, calculate gini index for other attributes also.
Since the gini index of outlook is very less, there are very less impurities. Hence
we select outlook as our root node.