randomForest (version 1.0)

predict.randomForest: predict method for random forest objects

Description

Prediction of test data using random forest.

Usage

## S3 method for class 'randomForest':
predict(object, newdata, type="class", norm.votes=TRUE, ...)

Arguments

object
an object of class randomForest, as that created by the function randomForest.
newdata
a data frame or matrix containing new data.
type
one of class, prob. or votes, indicating the type of output: predicted class, matrix of class probabilities, or matrix of vote counts.
norm.votes
Should the vote counts be normalized (i.e., expressed as fractions)?
...
not used currently.

Value

  • Depending on the argument type:
  • classpredicted class (the one with majority vote).
  • probmatrix of class probabilities (one column for each class and one row for each input).
  • votesmatrix of vote counts (one column for each class and one row for each new input); either in raw counts or in fractions (if norm.votes=TRUE).

References

Breiman, L., Random Forests, http://oz.berkeley.edu/users/breiman/randomforest2001.pdf.

See Also

randomForest

Examples

Run this code
data(iris)
set.seed(111)
n.iris <- nrow(iris)
iris.test <- sample(n.iris, round(n.iris/3), replace=FALSE)
iris.rf <- randomForest(Species ~ ., data=iris[-iris.test,])
iris.pred <- predict(iris.rf, iris[iris.test,])
table(observed = iris[iris.test,"Species"], predicted = iris.pred)

Run the code above in your browser using DataCamp Workspace