gini_index {rfVarImpOOB}R Documentation

compute Gini impurity for binary values only

Description

simple function to compute simple or penalized Gini impurity

The "penalty" compares the class probabilities pHat with a reference estimate pEst

which would typically serve as a prediction (e.g. in a tree node).

Usage

gini_index(pHat, pEst = NULL, k = 2, kind = 1, w = 2)

Arguments

pHat

probabilities from the current data,

pEst

estimated class probabilities (typically from an earlier inbag estimation). Only pass if you intend to compute the "validation-penalized Gini"

k

exponent of penalty term: abs(pHat-pEst)^k

kind

kind of penalty

w

weights, default is 2 if you pass just a single probability instead of the vector (p,1-p)

Value

simple or penalized Gini impurity

Author(s)

Markus Loecher <Markus.Loecher@gmail.com>

Examples



#Test binary case:





gini_index(0.5,0.5,kind=1)


gini_index(0.9,0.1,kind=1)


gini_index(0.1,0.9,kind=1)





gini_index(0.5,0.5,kind=2)


gini_index(0.9,0.1,kind=2)


gini_index(0.1,0.9,kind=2)








gini_index(0.5,0.5,kind=3)


gini_index(0.9,0.1,kind=3)


gini_index(0.1,0.9,kind=3)






[Package rfVarImpOOB version 1.0.3 Index]