Skip to contents

CART tree via rpart::rpart, returning the root split structure and feature importances.

Usage

morie_decision_tree_split(x, y, criterion = "gini", max_depth = 30L, seed = 0L)

Arguments

x

Numeric predictor matrix.

y

Response (factor for classification).

criterion

"gini" or "entropy" – only "gini" is supported by rpart for classification; "entropy" maps to information.

max_depth

Max tree depth.

seed

RNG seed.

Value

Named list: estimate, train_accuracy, root_feature, root_threshold, root_impurity, n_leaves, feature_importances, criterion, n, method.

Examples

morie_decision_tree_split(x = rnorm(50), y = rnorm(50))
#> $estimate
#> [1] 1
#> 
#> $train_accuracy
#> [1] 1
#> 
#> $root_feature
#> [1] 0
#> 
#> $root_threshold
#> [1] 0.09396981
#> 
#> $root_impurity
#> [1] 0.98
#> 
#> $n_leaves
#> [1] 50
#> 
#> $feature_importances
#> [1] 1
#> 
#> $criterion
#> [1] "gini"
#> 
#> $n
#> [1] 50
#> 
#> $method
#> [1] "Decision tree (CART, gini)"
#>