enter image description here

How do I compute the Gini index using Instance attribute as attribute test condition?

I calculated the Gini, but I have no clue how to do it for this Instance attribute.

$$\text{Gini for } a_1 = 0.345 $$ $$\text{Gini for } a_2 = 0.493 $$ $$\text{Gini for } a_3 = ?$$

I am guessing the answer to this is that Instance attribute has no information gain. However, I can't prove this.

$$\text{Gini} = 1 - \sum_i p(i|t)^2$$

  • $\begingroup$ Dear Mike, please decide on one SE site when posting your question. It is probably fine either here or on the math site, but whichever you choose, please flag the other one and ask that it be closed. Cheers. $\endgroup$ – cardinal Nov 22 '13 at 13:01
  • $\begingroup$ @cardinal Since it is unclear which of the two sites might be able to help with my question (since no one has answered) I will keep both until I get an answer in one. I think that is a fair assessment. $\endgroup$ – Mike John Nov 22 '13 at 13:15
  • 2
    $\begingroup$ Not so, as cross-posting is specifically discouraged: see stats.stackexchange.com/help/on-topic More to your point, I once counted four different meanings for Gini index, so just mentioning the term without a definition helps little. $\endgroup$ – Nick Cox Nov 22 '13 at 13:44
  • $\begingroup$ Fine, Math post has been closed. I added the Gini formula above if anyone still wants to actually help me. $\endgroup$ – Mike John Nov 22 '13 at 13:58

Gini index here ($G$, say) just calculates diversity or heterogeneity (or uncertainty if you will) from the sum of squared category probabilities. If every value is in the same category, then the measure is $1 - 1^2 = 0$. If every value of $n$ values is in a distinct category, then the measure is $1 - n(1/n)^2 = 1 - 1/n$. The complement is in some ways easier to think about, e.g. the reciprocal of the complement $1 / (1 - G)$ returns the "numbers equivalent", i.e. the equivalent number of equally common classes. Thus, the extremes for that are clearly $1/1$ and $1/(1/n)$, i.e. $1$ and $n$.

Your columns $a_1$ and $a_2$ have 4 T and 5 F and 5T and 4F, respectively, which I get to be the same index, namely $1 - (4/9)^2 - (5/9)^2 = .4938271605$; that's a ridiculous number of decimal places, but it suggests that you have a gross error for one column and a rounding error for the other. With your $a_3$ the principle does not change, as the index ignores labels on the categories: whatever metric meaning they might have is not considered. By my calculation you have $1 - 5((1/9)^2) - 2 ((2/9)^2) = .8395061728$.

Other names for this measure $G$ (or its complement, or the reciprocal of that) are Simpson, Herfindahl and repeat rate. Gini appears to have got there first, but its applications across ecology, economics, linguistics and many other fields are legion.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.