Skip to contents

IG = H(parent) - (mL/m) H(L) - (mR/m) H(R), impurity via morie_geron_shannon_entropy() or morie_geron_gini_impurity_grgin().

Usage

morie_geron_information_gain(y, left_mask, criterion = "entropy")

Arguments

y

Class labels.

left_mask

Logical (or 0/1) mask of the left child.

criterion

"entropy" or "gini".

Value

List with information_gain, parent_impurity, left_impurity, right_impurity, weighted_child_impurity, m_left, m_right.

Examples

y <- c(1, 1, 0, 0, 1, 0, 1, 1)
morie_geron_information_gain(y, left_mask = c(TRUE, TRUE, TRUE, FALSE,
                                              FALSE, FALSE, TRUE, FALSE))
#> $information_gain
#> [1] 0.04879494
#> 
#> $parent_impurity
#> [1] 0.954434
#> 
#> $left_impurity
#> [1] 0.8112781
#> 
#> $right_impurity
#> [1] 1
#> 
#> $weighted_child_impurity
#> [1] 0.9056391
#> 
#> $m_left
#> [1] 4
#> 
#> $m_right
#> [1] 4
#> 
#> $criterion
#> [1] "entropy"
#> 
#> $estimate
#> [1] 0.04879494
#> 
#> $n
#> [1] 8
#>