Gini Impurity

Gini impurity is used to calculate impurity of a leaf node in Decision Tree.

[!def] Equation of Gini Impurity
$$
\text{Gini impurity of Leaf} = 1 - \sum_c^C \text{(Probability of Class c)}^2
$$
$$
\text{Total Gini Impurity of Tree} = \sum_i \frac{\text{# of elements in branch}_i}{\text{Total # of elements in all branches}} \text{Gini Impurity of Branch}_i
$$