Entropy
Study guides: Exam MAS-II, Exam ACIA-CAPSTONE
The Entropy of a node in a classification decision tree is a measure of the node's impurity, taken from information theory:
D = -\sum_{k=1}^{K}\hat{p}_{mk}\ln\hat{p}_{mk}
\hat{p}_{mk}is the share of nodem's training observations in classk.Kis the number of classes.
The entropy is 0 for a pure node and largest when the classes are evenly mixed. For two classes it is D = -\hat{p}\ln\hat{p} - (1 - \hat{p})\ln(1 - \hat{p}), largest at \hat{p} = 0.5 with D = \ln 2 = 0.693. Base-2 logarithms, which give the entropy in bits, rescale every node's entropy by the same factor, so they never change which split wins. The entropy and the Gini index are numerically similar.
A node holds 40 large losses and 60 small losses. What is its entropy?
- The class shares are
0.40and0.60.D = -[0.40(-0.916) + 0.60(-0.511)] = 0.366 + 0.307 = 0.673.
Information gain
The information gain of a split is the reduction in entropy from it. When the split divides a node's n observations into n_L and n_R, the information gain is
\Delta D = D_{\text{parent}} - \frac{n_L}{n}D_L - \frac{n_R}{n}D_R
D_LandD_Rare the entropies of the two nodes the split creates.
The split with the largest information gain, which is the smallest weighted entropy of the two nodes, is chosen.
A node of 100 observations has entropy
0.693. A split leaves 60 observations with entropy0.5and 40 with entropy0.2. What is the information gain?
- The weighted entropy after the split is
0.6(0.5) + 0.4(0.2) = 0.38.\Delta D = 0.693 - 0.38 = 0.313.