
Gini impurity (Geron Ch 6, morie.fn hmgini)
Source:R/geron_ml2_native.R
morie_geron_gini_impurity.RdG = 1 - sum_k p_k^2, with the K-class ceiling 1 - 1/K reported so a value can be read against its own maximum.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_gini_impurity(V)
#> $gini
#> [1] 0.875
#>
#> $proportions
#> [1] 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125
#>
#> $classes
#> [1] 1 2 3 4 5 6 7 8
#>
#> $counts
#> [1] 1 1 1 1 1 1 1 1
#>
#> $n_classes
#> [1] 8
#>
#> $max_possible
#> [1] 0.875
#>
#> $estimate
#> [1] 0.875
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Gini impurity G = 1 - sum_k p_k^2"
#>