Gini Index
Study guides: Exam MAS-II, Exam PCPA, Exam ACIA-CAPSTONE
The Gini Index of a node in a classification decision tree is a measure of the node's impurity:
G = \sum_{k=1}^{K}\hat{p}_{mk}(1 - \hat{p}_{mk})
G = 1 - \sum_{k=1}^{K}\hat{p}_{mk}^{2}
\hat{p}_{mk}is the share of nodem's training observations in classk.Kis the number of classes.
The Gini index is 0 for a pure node and 1 - 1/K when the classes are evenly mixed. For two classes it is G = 2\hat{p}(1 - \hat{p}), largest at \hat{p} = 0.5 with G = 0.5. The Gini index and the entropy are numerically similar, and either is used to judge a split, because both are more sensitive to node purity than the classification error rate.
A node holds 30 fraud and 70 legitimate claims. What is its Gini index?
- The class shares are
0.30and0.70.G = 1 - (0.30^2 + 0.70^2) = 1 - 0.58 = 0.42.
Gini index of a rating model
The Gini index also names a separate measure of the lift of a rating model, built from a Lorenz curve. Sort the holdout data by predicted loss cost, lowest first, and plot the cumulative share of exposure x against the cumulative share of actual losses L(x). The Gini index is twice the area between that Lorenz curve and the line of equality:
\text{Gini} = 1 - 2\int_0^1 L(x)\,dx
The line of equality is the 45-degree line from (0, 0) to (1, 1), with area 0.5 under it. A model that ranks nothing puts losses in proportion to exposure, so L(x) = x and Gini = 0. The better the model separates low-cost from high-cost risks, the further the curve bows below the diagonal and the higher the Gini index.
The Gini index measures ranking only, not calibration. Multiplying every prediction by 1.2 leaves the sort order, and so the Gini index, unchanged, so it is paired with a quantile plot. Gini indices of different models are compared on the same holdout data, because on training data the more flexible model always wins.
A holdout set is sorted by predicted pure premium into four equal-exposure groups, holding 10%, 20%, 30% and 40% of actual losses from lowest prediction to highest. Estimate the Gini index using the trapezoid rule.
- The cumulative loss shares at
x = 0.25, 0.50, 0.75, 1areL = 0.10, 0.30, 0.60, 1.- Each trapezoid's area is its width times the average of its two heights, so the area under the curve is
0.25(0.05 + 0.20 + 0.45 + 0.80) = 0.375.\text{Gini} = 1 - 2(0.375) = 0.25.
Normalized Gini index
For a binary model, the data are sorted by predicted probability, and cumulative risks are plotted against cumulative occurrences of the event. The normalized Gini index is the model's Gini index divided by that of a perfect model, and it is tied to the AUROC:
\text{normalized Gini} = 2\,\text{AUROC} - 1
One can be derived from the other, so the two are not separate validation metrics.
A logistic model has an AUROC of
0.78. What is its normalized Gini index?
\text{normalized Gini} = 2(0.78) - 1 = 0.56.- A model with no predictive power has an AUROC of
0.5and a normalized Gini index of0.
Two different Gini indices The Gini index of a tree node and the Gini index of a rating model share a name and nothing else. A node's Gini index is small when the node is pure, while a rating model's is large when the model ranks risks well.