Pruning for Bagging
prune.bagging.RdPrune each of the trees returned by bagging.
Usage
# S3 method for class 'classbagg'
prune(tree, cp=0.01,...)Arguments
- tree
an object returned by
bagging(calling thistreeis needed by the generic functionprunein packagerpart).- cp
complexity parameter, see
prune.rpart.- ...
additional arguments to
prune.rpart.
Details
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.
Examples
data("Glass", package = "mlbench")
library("rpart")
mod <- bagging(Type ~ ., data=Glass, nbagg=10, coob=TRUE)
pmod <- prune(mod)
print(pmod)
#>
#> Bagging classification trees with 10 bootstrap replications
#>
#> Call: bagging.data.frame(formula = Type ~ ., data = Glass, nbagg = 10,
#> coob = TRUE)
#>
#> Out-of-bag estimate of misclassification error: 0.2944
#>