I am trying to determine the root node for the decision tree on given data
annual income
target variable has been renamed as low
, mid
, and high
.
I am using gini index to measure the impurity of my nodes.
The process I am following is simple:
1- calculate the Gini index for the dataset(target is annual income)
gini(annual income)=1-((5/20)^2+(12/20)^2+(3/20)^2) = 0.445
2 - for each variable calculate gini and then remainder and information gain
3 - choose variable with the highest information gain
just instead of entropy, I am using gini
when I am trying to calculate information gain if education becomes root note I am getting a negative information gain (which is obviously not possible)
as you can see I got a gini index of 0.532 for the node if I do
Information gain (0.445-0.532)=-ve value
can you point towards what am I doing wrong