importance: Extract variable importance measure

Description Usage Arguments Details Value See Also Examples

View source: R/importance.R

Description

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

Usage

1
2
## 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.

Details

Here are the definitions of the variable importance measures. The first measure is computed from permuting OOB data: For each tree, the prediction error on the out-of-bag portion of the data is recorded (error rate for classification, MSE for regression). Then the same is done after permuting each predictor variable. The difference between the two are then averaged over all trees, and normalized by the standard deviation of the differences. If the standard deviation of the differences is equal to 0 for a variable, the division is not done (but the average is almost always equal to 0 in that case).

The second measure is the total decrease in node impurities from splitting on the variable, averaged over all trees. For classification, the node impurity is measured by the Gini index. For regression, it is measured by residual sum of squares.

Value

A matrix of importance measure, one row for each predictor variable. The column(s) are different importance measures.

See Also

randomForest, varImpPlot

Examples

1
2
3
4
data(iris)
set.seed(4543)
iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE)
importance(iris.rf)

Example output

iRF 2.0.0
                setosa versicolor virginica MeanDecreaseAccuracy
Sepal.Length  6.313799   7.593799  8.124998            10.912764
Sepal.Width   4.415782   1.599136  4.922792             5.245905
Petal.Length 23.377212  33.153940 27.073631            33.196803
Petal.Width  20.779947  32.061368 30.041729            32.029587
             MeanDecreaseGini
Sepal.Length        10.402654
Sepal.Width          2.386042
Petal.Length        42.511467
Petal.Width         43.921297

iRF documentation built on May 2, 2019, 11:02 a.m.