Prunes all trees in the forest and re-calculates the out-of-bag predictions and performance measures. The training data is needed to calculate the out-of-bag statistics. Note that the forest is pruned in place. If you intend to keep the original forest, make a copy of it before pruning.

# S3 method for class 'SDForest'
prune(object, cp, X = NULL, Y = NULL, Q = NULL, pred = TRUE, ...)

Arguments

object

an SDForest object

cp

Complexity parameter, the higher the value the more nodes are pruned.

X

The training data, if NULL the data from the forest object is used.

Y

The training response variable, if NULL the data from the forest object is used.

Q

The transformation function, if NULL the data from the forest object is used.

pred

If TRUE the predictions are calculated, if FALSE only the out-of-bag statistics are calculated. This can set to FALSE to save computation time if only the out-of-bag statistics are needed.

...

Further arguments passed to or from other methods.

Value

A pruned SDForest object

Author

Markus Ulmer

Examples


set.seed(1)
X <- matrix(rnorm(10 * 20), nrow = 10)
Y <- rnorm(10)
fit <- SDForest(x = X, y = Y, nTree = 2)
pruned_fit <- prune(copy(fit), 0.2)