Gini impurity measures how mixed a labeled dataset is. A value of 0 means every example has the same class; larger values indicate greater uncertainty. Decision trees use it to judge whether a proposed question makes the data cleaner. section 8.17
A bag of diamonds
A bag containing five Perfect and five Okay diamonds is maximally mixed, with a Gini index of 0.5. A bag containing ten Perfect diamonds has a Gini index of 0. After testing feature questions, the tree compares the weighted impurity of the resulting groups with the original impurity; the reduction is information gain. section 8.17
Figure 8.21 The Gini index calculation
Use the calculation figure to connect class proportions with the impurity score. section 8.17




