Last chance! 50% off unlimited learning
Sale ends in
Prune each of the trees returned by bagging
.
# S3 method for classbagg
prune(tree, cp=0.01,...)
An object of the same class as tree
with the trees pruned.
an object returned by bagging
(calling this tree
is needed by the generic function
prune
in package rpart
).
complexity parameter, see prune.rpart
.
additional arguments to prune.rpart
.
By default, bagging
grows classification
trees of maximal size. One may want to prune each tree, however,
it is not clear whether or not this may decrease prediction error.
data("Glass", package = "mlbench")
library("rpart")
mod <- bagging(Type ~ ., data=Glass, nbagg=10, coob=TRUE)
pmod <- prune(mod)
print(pmod)
Run the code above in your browser using DataLab