randomForest (version 4.3-2)

importance: Extract variable importance measure

Description

This is the extractor function for variable importance measures as produced by randomForest.

Usage

## S3 method for class 'randomForest':
importance(x, type=NULL, class=NULL, scale=TRUE, ...)

Arguments

x
an object of class randomForest
type
either 1 or 2, specifying the type of importance measure (1=mean decrease in accuracy, 2=mean decrease in node impurity).
class
for classification problem, which class-specific measure to return.
scale
For permutation based measures, should the measures be divided their ``standard errors''?
...
not used.

Value

  • If class and type are NULL, A matrix of p rows and nclass + 2 columns (where p is the number of variables in the data and nclass is the number of classes) for classification problem, or p rows and 2 columns for regression. In the classification case, the first nclass columns are the class-specific importance measures (based on permutation of out-of-bag data). The nclass+1st column is the overall importance, and the last column is the overall measure based on the decrease in node purity (or `Gini-based' measure).

    If either type or class is given, it returns a (named) vector of importance measure, one for each predictor variable.

example

set.seed(4543) data(mtcars) mtcars.rf <- randomForest(mpg ~ ., data=mtcars, ntree=1000, keep=FALSE, importance=TRUE) importance(mtcars.rf) importance(mtcars.rf, type=1)

Details

See the documentation for randomForest for explanation of how the importance measures are computed.

See Also

randomForest, varImpPlot