
CART split cost at a node (Geron Ch 5 Eq 5-2, morie.fn grcart)
Source:R/geron_ml_native.R
morie_geron_cart_split_cost.RdJ = (m_L/m) G_L + (m_R/m) G_R, with gini, entropy (log base 2) or mse impurity, plus the impurity decrease against the parent.
Value
List with cost, impurity_left, impurity_right,
impurity_parent, impurity_decrease, n_left, n_right.
Examples
X <- matrix(c(1, 2, 3, 4), ncol = 1)
morie_geron_cart_split_cost(X, c(0, 0, 1, 1), 0, 1.5)
#> $cost
#> [1] 0.3333333
#>
#> $impurity_left
#> [1] 0
#>
#> $impurity_right
#> [1] 0.4444444
#>
#> $impurity_parent
#> [1] 0.5
#>
#> $impurity_decrease
#> [1] 0.1666667
#>
#> $n_left
#> [1] 1
#>
#> $n_right
#> [1] 3
#>
#> $criterion
#> [1] "gini"
#>
#> $threshold
#> [1] 1.5
#>
#> $feature
#> [1] 0
#>
#> $estimate
#> [1] 0.3333333
#>
#> $n
#> [1] 4
#>
#> $method
#> [1] "CART split cost"
#>