0% found this document useful (0 votes)
39 views

Gini Algorithm

The document appears to contain demographic and medical data for multiple patients. It includes columns for age, prescription type, astigmatism, tears, and class. The Gini coefficient, which measures inequality, was calculated for each column and ranged from 0 to 0.633, with tears having the lowest inequality and prescription type having the highest. The data was further stratified and subsets were analyzed to determine relationships between the different attributes.

Uploaded by

Shams Pushan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Gini Algorithm

The document appears to contain demographic and medical data for multiple patients. It includes columns for age, prescription type, astigmatism, tears, and class. The Gini coefficient, which measures inequality, was calculated for each column and ranged from 0 to 0.633, with tears having the lowest inequality and prescription type having the highest. The data was further stratified and subsets were analyzed to determine relationships between the different attributes.

Uploaded by

Shams Pushan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Age specRx astig tear class

1 1 1 1 3
1 1 1 2 2
1 1 2 1 3
1 1 2 2 1
1 2 1 1 3
1 2 1 2 2
1 2 2 1 3
1 2 2 2 1
2 1 1 1 3
2 1 1 2 2
2 1 2 1 3
2 1 2 2 1
2 2 1 1 3
2 2 1 2 2
2 2 2 1 3
2 2 2 2 3
3 1 1 1 3
3 1 1 2 3
3 1 2 1 3
3 1 2 2 1
3 2 1 1 3
3 2 1 2 2
3 2 2 1 3
3 2 2 2 3

Age:
1 2 3
1 2 2 4
2 1 2 5
3 1 1 6
Gini(1) = 1- (2/8)2-(2/8)2-(4/8)2 = 0.625
Gini(2) = 1- (1/8)2-(2/8)2-(5/8)2 = 0.531
Gini(3) = 1- (1/8)2-(1/8)2-(6/8)2 = 0.406
Gini(Age) = (8/24)*0.625 + (8/24)*0. 531+ (8/24)*0. 406= 0.521
specRx:
1 2 3
1 3 2 7
2 1 3 8
Gini(1) = 1- (3/13)2-(2/13)2-(7/13)2 = 0.633
Gini(2) = 1- (1/11)2-(3/11)2-(8/11)2 = 0.388
Gini(specRx) = (13/24)*0. 633+ (11/24)*0. 388= 0.521

astig:
1 2 3
1 0 5 7
2 4 0 8
Gini(1) = 1- (0/12)2-(5/12)2-(7/12)2 = 0.486
Gini(2) = 1- (4/12)2-(0/12)2-(8/12)2 = 0.444
Gini(astig) = (12/24)*0.486+ (12/24)*0.444= 0.465

tears:
1 2 3
1 0 0 12
2 4 5 3
Gini(1) = 1- (0/12)2-(0/12)2-(12/12)2 = 0
Gini(2) = 1- (4/11)2-(5/12)2-(3/12)2 = 0.653
Gini(tears) = (12/24)*0+ (12/24)*0.653= 0.327

Gini(Age) 0.521
Gini(specRx) 0.521
Gini(astig) 0.465
Gini(tears) 0.327

tears
1 2

age = 3
tears = 2
Age specRx astig tear class
1 1 1 2 2
1 1 2 2 1
1 2 1 2 2
1 2 2 2 1
2 1 1 2 2
2 1 2 2 1
2 2 1 2 2
2 2 2 2 3
3 1 1 2 3
3 1 2 2 1
3 2 1 2 2
3 2 2 2 3

Age:
1 2 3
1 2 2 0
2 1 2 1
3 1 1 2
Gini(1) = 1- (2/4)2-(2/4)2-(0/4)2 = 0.5
Gini(2) = 1- (1/4)2-(2/4)2-(1/4)2 = 0.625
Gini(3) = 1- (1/4)2-(1/4)2-(2/4)2 = 0. 625
Gini(Age) = (4/12)*0.5+ (4/12)*0.625+ (4/12)*0.625= 0.583

specRx:
1 2 3
1 3 2 1
2 1 3 2
Gini(1) = 1- (3/6)2-(2/6)2-(1/6)2 = 0.611
Gini(2) = 1- (1/6)2-(3/6)2-(2/6)2 = 0.611
Gini(specRx) = (6/12)*0.611+ (6/12)*0.611= 0.611

astig:
1 2 3
1 0 5 1
2 4 0 2
Gini(1) = 1- (0/6)2-(5/6)2-(1/6)2 = 0.278
Gini(2) = 1- (4/6)2-(0/6)2-(2/6)2 = 0.444
Gini(astig) = (6/12)*0.278+ (6/12)*0.444= 0.362
Gini(Age) 0.583
Gini(specRx) 0.611
Gini(astig) 0.362

tears
1 2

age = 3 astig
1 2

tears = 2 & astig = 1


Age specRx astig tear class
1 1 1 2 2
1 2 1 2 2
2 1 1 2 2
2 2 1 2 2
3 1 1 2 3
3 2 1 2 2

Age:
1 2 3
1 0 2 0
2 0 2 0
3 0 1 1
Gini(1) = 1- (0/2)2-(2/2)2-(0/2)2 = 0
Gini(2) = 1- (0/2)2-(2/2)2-(0/2)2 = 0
Gini(3) = 1- (0/2)2-(1/2)2-(1/2)2 = 0.5
Gini(Age) = (2/6)*0+ (2/6)*0 + (2/6)*0.5= 0.167
specRx:
1 2 3
1 0 2 1
2 0 3 0
Gini(1) = 1- (0/3)2-(2/3)2-(1/3)2 = 0.444
Gini(2) = 1- (0/3)2-(3/3)2-(0/3)2 = 0
Gini(specRx) = (3/6)*0.444+ (3/6)*0= 0.222

Gini(Age) 0.167
Gini(specRx) 0.222

tears
1 2

class = 3 astig
1 2

age

1 2 3

class =2 class = 2 specRx

1 2

class = 3 class = 2
tears = 2 & astig = 2
Age specRx astig tear class
1 1 2 2 1
1 2 2 2 1
2 1 2 2 1
2 2 2 2 3
3 1 2 2 1
3 2 2 2 3

Age:
1 2 3
1 2 0 0
2 1 0 1
3 1 0 1
Gini(1) = 1- (2/2)2-(0/2)2-(0/2)2 = 0
Gini(2) = 1- (1/2)2-(0/2)2-(1/2)2 = 0.5
Gini(3) = 1- (1/2)2-(0/2)2-(1/2)2 = 0.5
Gini(Age) = (2/6)*0+ (2/6)*0.5 + (2/6)*0.5= 0.333

specRx:
1 2 3
1 3 0 0
2 1 0 2
Gini(1) = 1- (3/3)2-(0/3)2-(0/3)2 = 0
Gini(2) = 1- (1/3)2-(0/3)2-(2/3)2 = 0.444
Gini(specRx) = (3/6)*0+ (3/6)*0.444= 0.222

Gini(Age) 0.333
Gini(specRx) 0.222
tears
1 2

class = 3 astig
1 2

age specRx

1 2 3 1 2

class =2 class = 2 specRx class = 1 age

1 2 1 2 3

class = 3 class = 2 class = 1 class = 3 class = 3

You might also like