randomForest

0th

Percentile

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.

Keywords
classif
Usage
## 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, ...)
Arguments
formula
a symbolic description of the model to be fitted.
data
an optional data frame containing the variables in the model. By default the variables are taken from the environment which randomForest is called from.
subset
an index vector indicating which rows should be used.
x
a data frame or a matrix of predictors (for the print method, an randomForest object).
y
A response vector, must be a factor, with the levels specifying the class membership. If omitted, randomForest will run in unsupervised mode with addclass=1 (unless explicitly set otherwise).
addclass
=0 (default) do not add a synthetic class to the data. =1 label the input data as class 1 and add a synthetic class by randomly sampling from the product of empirical marginal distributions of the input. =2
ntree
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.
mtry
Number of variables randomly sampled as candidates at each split.
classwt
Priors of the classes. Need not add up to one.
nodesize
Minimum size of terminal nodes. Setting this number larger causes smaller trees to be grown (and thus take less time).
importance
Should importance of predictors be assessed?
proximity
Should proximity measure among the rows be calculated?
outscale
Should outlyingness of rows be assessed?
norm.votes
If 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).
do.trace
If set to TRUE, give a more verbose output as randomForest is run.
...
optional parameters to be passed to the low level function randomForest.default.
Value

  • An object of class randomForest, which is a list with the following components:
  • callthe original call to randomForest
  • supervisedTRUE if input data have class labels, FALSE otherwise.
  • predictedthe predicted class of the input data.
  • err.ratefinal error rate of the prediction on the input data.
  • confusionthe confusion matrix of the prediction.
  • votesa 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.
  • importancea matrix with four columns, each a different measure of importance of the predictors (NULL if importance=FALSE when randomForest is called, this component is set to NULL).
  • proximityif proximity=TRUE when randomForest is called, a matrix of proximity measures among the input (based on the frequency that pairs of data points are in the same terminal nodes).
  • outlierif outscale=TRUE when randomForest is called, a vector indicating how outlying the data points are (based on the proximity measures).
  • ntreenumber of trees grown.
  • mtrynumber of predictors sampled for spliting at each node.
  • foresta list that contains the entire forest; NULL if randomForest is run in unsupervised mode.

References

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

See Also

predict.randomForest

Aliases
  • randomForest
  • randomForest.formula
  • randomForest.default
  • print.randomForest
Examples
data(iris)
iris.rf <- randomForest(Species ~ ., data=iris)
print(iris.rf)
Documentation reproduced from package randomForest, version 1.0, License: GPL version 2 or later

Community examples

Looks like there are no examples yet.