Breiman's Random Forest classifier
randomForest implements Breiman's random forest algorithm (based on
Breiman and Cutler's original Fortran code) for classification. It
can also be used in unsupervised mode for locating outliers or
assessing proximities among data points.
## S3 method for class 'formula': randomForest(formula, data=NULL, subset, ...) ## S3 method for class 'default': randomForest(x, y=NULL, addclass=0, ntree=100, mtry=ceiling(sqrt(ncol(x))), classwt=NULL, nodesize=1, importance=FALSE, proximity=FALSE, outscale=FALSE, norm.votes=TRUE, do.trace=FALSE, ...) ## S3 method for class 'randomForest': print(x, ...)
- a symbolic description of the model to be fitted.
- an optional data frame containing the variables in the model.
By default the variables are taken from the environment which
randomForestis called from.
- an index vector indicating which rows should be used.
- a data frame or a matrix of predictors (for the
- A response vector, must be a factor, with the levels
specifying the class membership. If omitted,
randomForestwill run in unsupervised mode with
addclass=1(unless explicitly set otherwise).
=0(default) do not add a synthetic class to the data.
=1label the input data as class 1 and add a synthetic class by randomly sampling from the product of empirical marginal distributions of the input.
- Number of trees to grow. This should not be set to too small a number, to ensure that every input row gets predicted at least a few times.
- Number of variables randomly sampled as candidates at each split.
- Priors of the classes. Need not add up to one.
- Minimum size of terminal nodes. Setting this number larger causes smaller trees to be grown (and thus take less time).
- Should importance of predictors be assessed?
- Should proximity measure among the rows be calculated?
- Should outlyingness of rows be assessed?
TRUE(default), the final result of votes are expressed as fractions. If
FALSE, raw vote counts are returned (useful for combining results from different runs).
- If set to
TRUE, give a more verbose output as
- optional parameters to be passed to the low level function
- An object of class
randomForest, which is a list with the following components:
call the original call to
TRUEif input data have class labels,
predicted the predicted class of the input data. err.rate final error rate of the prediction on the input data. confusion the confusion matrix of the prediction. votes a matrix with one row for each input data point and one column for each class, giving the fraction or number of `votes' from the random forest. importance a matrix with four columns, each a different measure of importance of the predictors (
randomForestis called, this component is set to
randomForestis called, a matrix of proximity measures among the input (based on the frequency that pairs of data points are in the same terminal nodes).
randomForestis called, a vector indicating how outlying the data points are (based on the proximity measures).
ntree number of trees grown. mtry number of predictors sampled for spliting at each node. forest a list that contains the entire forest;
randomForestis run in unsupervised mode.
Breiman, L., Random Forests,
data(iris) iris.rf <- randomForest(Species ~ ., data=iris) print(iris.rf)