predict.randomForest
From randomForest v1.0
by Andy Liaw
predict method for random forest objects
Prediction of test data using random forest.
- Keywords
- classif
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 functionrandomForest
. - newdata
- a data frame or matrix containing new data.
- type
- one of
class
,prob
. orvotes
, 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
: class predicted class (the one with majority vote). prob matrix of class probabilities (one column for each class and one row for each input). votes matrix 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,
See Also
Examples
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)
Community examples
Looks like there are no examples yet.