Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

prune.bagging

Pruning for Bagging


Description

Prune 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 this tree is needed by the generic function prune in package rpart).

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.

Value

An object of the same class as tree with the trees pruned.

Examples

data("Glass", package = "mlbench")
library("rpart")

mod <- bagging(Type ~ ., data=Glass, nbagg=10, coob=TRUE)
pmod <- prune(mod)
print(pmod)

ipred

Improved Predictors

v0.9-11
GPL (>= 2)
Authors
Andrea Peters [aut], Torsten Hothorn [aut, cre], Brian D. Ripley [ctb], Terry Therneau [ctb], Beth Atkinson [ctb]
Initial release
2021-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.