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

prune.rpart

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 "rpart". This is assumed to be the result of some function that produces an object with the same named components as that returned by the rpart function.

cp

Complexity parameter to which the rpart object will be trimmed.

...

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

rpart

Recursive Partitioning and Regression Trees

v4.1-15
GPL-2 | GPL-3
Authors
Terry Therneau [aut], Beth Atkinson [aut, cre], Brian Ripley [trl] (producer of the initial R port, maintainer 1999-2017)
Initial release
2019-04-10

We don't support your browser anymore

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