Mirrors the C# DecisionTree class: recursively splits the training data on the feature and
threshold that most reduce variance (regression) or most increase information gain
(classification), then predicts by walking a new observation down the tree.
Usage
ml_decision_tree(
x,
y,
newdata,
seed = NULL,
regression = TRUE,
features = NULL,
minimum_split_size = 2,
max_depth = 100
)Arguments
- x
a numeric matrix or data frame of training predictors, one row per observation.
- y
the training response, one value per row of
x.- newdata
predictors to predict for, with the same number of columns as
x.- seed
integer PRNG seed for the random feature subsets;
NULLuses the computer clock.- regression
TRUE(the default) fits a regression tree;FALSEa classifier.- features
the number of random features to consider at each split.
NULL(the default) uses the library's ownmax(1, ncol(x) - 1).- minimum_split_size
the smallest node the tree will split. Default 2.
- max_depth
the recursion cap. Default 100.
Details
At the library's defaults a REGRESSION tree recurses until every leaf holds a single training
observation, so it memorizes the training data and generalizes poorly. That is upstream's
behaviour, not a port artifact, and it is why ml_random_forest() exists. Set
minimum_split_size or max_depth to regularize it.
See also
ml_random_forest(), which averages many bootstrapped trees.