Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Gini Calculation

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 126
Accepted Solution

Gini Calculation

Hi all,

Any ideas on how the gini measure of diversity  is calculated when creating bins through the interactive binning node? cause i see it alters when i either merge or spliit bins

Thank you in advance


Accepted Solutions
Solution
‎09-24-2013 05:06 PM
SAS Employee
Posts: 68

Re: Gini Calculation

Hi, thanks to one of my R&D colleagues, he wrote up a quick solution using IML, which should match your results in EM.

proc iml;

event={517,365,349,269};

nonevent={233,281,451,535};

sum1=0;

do i=2 to 4;

     sum2=0;

     im1=i-1;

      do j=1 to im1;

sum2=sum2+nonevent;

end;

sum1=sum1 + event*sum2;

end;

sum3=0;

do i=1 to 4;

sum3 = sum3 + event*nonevent;

end;

gini = 100*(1 - (2*sum1 + sum3)/ (1500*1500)) ;

print sum1 sum2 sum3 gini;

quit;


524016

965

524340

30.1168

View solution in original post


All Replies
SAS Employee
Posts: 68

Re: Gini Calculation

Hi as you may already know, the Gini statistic tests for differences in bin values with respect to the target (events vs non-events).  As Gini changes in the Interactive Binning node, you get an idea of the validity of your bin cutoffs.

You can find this equation in the EM reference guide in the Interactive Binning node section.

gini.png

Thanks,

Jonathan

Frequent Contributor
Posts: 126

Re: Gini Calculation

Ok i think i am almost there, but how would the formula look like in the following example?

Value

GroupCutoffEvent countNon event countTotalEvent rate
MISSING1 0000
AGE <25225.551723375068.9%
25.5<AGE<3133136528164656.5%
31.5<AGE<40431.534945180043.6%
40<AGE5 26953580433.5%

Thank you in advance

Solution
‎09-24-2013 05:06 PM
SAS Employee
Posts: 68

Re: Gini Calculation

Hi, thanks to one of my R&D colleagues, he wrote up a quick solution using IML, which should match your results in EM.

proc iml;

event={517,365,349,269};

nonevent={233,281,451,535};

sum1=0;

do i=2 to 4;

     sum2=0;

     im1=i-1;

      do j=1 to im1;

sum2=sum2+nonevent;

end;

sum1=sum1 + event*sum2;

end;

sum3=0;

do i=1 to 4;

sum3 = sum3 + event*nonevent;

end;

gini = 100*(1 - (2*sum1 + sum3)/ (1500*1500)) ;

print sum1 sum2 sum3 gini;

quit;


524016

965

524340

30.1168

Frequent Contributor
Posts: 126

Re: Gini Calculation

Thank you very much for your help

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 2766 views
  • 0 likes
  • 2 in conversation