predict.randomForest {RFO} | R Documentation |
Prediction of test data using random forest.
## S3 method for class 'randomForest' predict(object, newdata, type = "response", norm.votes = TRUE, cutoff, ...)
object |
an object of class |
newdata |
a data frame or matrix containing new data. |
type |
one of |
norm.votes |
Should the vote counts be normalized (i.e., expressed as fractions)? |
cutoff |
A vector of length equal to number of classes.
The ‘winning’ class for an observation is the
one with the maximum ratio of proportion of votes to cutoff.
Default is taken from the |
... |
not used currently. |
If object$type
is classification
, the object returned
depends on the argument type
:
response |
predicted classes (the classes with majority vote). |
prob |
matrix of class probabilities (one column for each class and one row for each input). |
vote |
matrix of vote counts (one column for each class
and one row for each new input); either in raw counts or in fractions
(if |
The function currently does not support object$type
regression
.
NOTE: Any data with NA
is silently omitted from the prediction.
The returned value will contain NA
correspondingly in the prediction.
NOTE2: Any ties are broken at random.
Lei Zhang lei.c.zhang@oracle.com, Andy Liaw andy\_liaw@merck.com and Matthew Wiener matthew\_wiener@merck.com, based on original Fortran code by Leo Breiman and Adele Cutler.
Breiman, L. (2001), Random Forests, Machine Learning 45(1), 5-32.
data(iris) set.seed(111) ind <- sample(2, nrow(iris), replace = TRUE, prob=c(0.8, 0.2)) iris.rf <- randomForest(Species ~ ., data=iris[ind == 1,]) iris.pred <- predict(iris.rf, iris[ind == 2,]) table(observed = iris[ind==2, "Species"], predicted = iris.pred)