This function builds a classification model using CART.
CART(
train,
labels,
minsplit = 1,
maxdepth = log2(length(labels)),
cp = NULL,
xval = 10,
tune = FALSE,
methodparameters = NULL,
graph = FALSE,
seed = NULL,
...
)The classification model.
The training set (description), as a data.frame.
Class labels of the training set (vector or factor).
The minimum leaf size during the learning.
Set the maximum depth of any node of the final tree, with the root node counted as depth 0.
The complexity parameter of the tree. Cross-validation is used to determine optimal cp if NULL.
The number of cross-validation folds used to choose cp, when cp is
NULL. xval = nrow (train) gives a leave-one-out cross-validation, which fits
one tree per observation and costs about nrow (train) / 10 times as much.
If true, the function returns parameters instead of a classification model.
Present for interface consistency with performance
(which always passes it when fitting a model). Currently unused: CART does not
support reusing pre-tuned parameters.
Present for interface consistency with performance (which always
passes it when fitting a model). Currently unused: CART does not produce a plot.
A specified seed for random number generation, so that two runs on the same data give the same model. Every learning method accepts it, so that it can be set the same way whatever the method; the deterministic ones simply have nothing to draw and give the same model with or without it.
Other parameters.
cartdepth, cartinfo, cartleafs, cartnodes, cartplot, rpart
require (datasets)
data (iris)
CART (iris [, -5], iris [, 5])
Run the code above in your browser using DataLab