Skip to contents

Greedy binary splits minimising the within-node sum of squares (ESL eqs 9.10-9.13), midpoint thresholds, stopped by depth and minimum leaf size (not pruned); matches rpart's anova splits with cp = 0.

Usage

morie_esl_decision_tree(
  X,
  y,
  max_depth = 3,
  min_leaf = 1,
  min_impurity_decrease = 0
)

Arguments

X

Predictors, n by p.

y

Response.

max_depth, min_leaf, min_impurity_decrease

Stopping rules.

Value

Named list: estimate (training RSS), tree (nested nodes with 1-based feature), n_leaves, depth, fitted, n, p.

References

Breiman, L., Friedman, J., Olshen, R. & Stone, C. (1984). Classification and Regression Trees.

Examples

i <- 1:60
X <- cbind(((7 * i) %% 59) / 59 * 3, ((11 * i) %% 61) / 61 * 2)
morie_esl_decision_tree(X, sin(2 * X[, 1]) + (X[, 2] > 1.1), max_depth = 2)$n_leaves
#> [1] 4