prune.rpart {rpart} | R Documentation |
Cost-complexity Pruning of an Rpart Object
Description
Determines a nested sequence of subtrees of the supplied rpart
object
by recursively snipping
off the least important splits, based on the
complexity parameter (cp
).
Usage
prune(tree, ...)
## S3 method for class 'rpart'
prune(tree, cp, ...)
Arguments
tree |
fitted model object of class |
cp |
Complexity parameter to which the |
... |
further arguments passed to or from other methods. |
Value
A new rpart
object that is trimmed to the value cp
.
See Also
Examples
z.auto <- rpart(Mileage ~ Weight, car.test.frame)
zp <- prune(z.auto, cp = 0.1)
plot(zp) #plot smaller rpart object
[Package rpart version 4.1.23 Index]