# importance: Extract variable importance measure In randomForest: Breiman and Cutler's Random Forests for Classification and Regression

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

`randomForest`, `varImpPlot`

## Examples

 ```1 2 3 4 5 6``` ```set.seed(4543) data(mtcars) mtcars.rf <- randomForest(mpg ~ ., data=mtcars, ntree=1000, keep.forest=FALSE, importance=TRUE) importance(mtcars.rf) importance(mtcars.rf, type=1) ```

### Example output

```randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
%IncMSE IncNodePurity
cyl  16.208012     175.57529
disp 17.799412     234.65265
hp   18.129872     190.21859
drat  5.958783      61.17834
wt   19.981446     268.18939
qsec  5.674305      31.13353
vs    6.146763      32.52011
am    5.018332      17.63306
gear  3.301661      16.44901
carb  9.244852      31.14588
%IncMSE
cyl  16.208012
disp 17.799412
hp   18.129872
drat  5.958783
wt   19.981446
qsec  5.674305
vs    6.146763
am    5.018332
gear  3.301661
carb  9.244852
```

randomForest documentation built on May 2, 2019, 3:26 p.m.