ipred (version 0.4-0)

predict.bagging: Predictions from a Bagging Object

Description

Predict the outcome of a new observation using bagged trees.

Usage

predict.bagging(object, newdata=NULL,...)

Arguments

object
object of class bagging.
newdata
new observations.
...
additional arguments.

Value

  • The predicted class or endpoint in regression of all observations are returned.

Details

The predicted class is derived from majority voting over the classes predicted by all classification trees. In the regression framework, the mean of the predictions is returned.

References

Leo Breiman (1996), Bagging Predictors. Machine Learning 24(2), 123--140.

Examples

Run this code
X <- as.data.frame(matrix(rnorm(1000), ncol=10))
y <- factor(ifelse(apply(X, 1, mean) > 0, 1, 0))

mt <- bagging(y, X)

X <- as.data.frame(matrix(rnorm(1000), ncol=10))
y <- factor(ifelse(apply(X, 1, mean) > 0, 1, 0))

cls <- predict(mt, X)

cat("error: ", sum(y != cls)/length(cls), "")

Run the code above in your browser using DataLab