I have trained a regression forest using the R package ranger. Now I would like to discuss the variable importance measures of the included features. However, I am having difficulties understanding the exact definition of the different importance measures offered by ranger.

The documentation of the ranger function states the following about the argument 'importance':

Variable importance mode, one of ’none’, ’impurity’, ’impurity_corrected’, ’permutation’. The ’impurity’ measure is the Gini index for classification, the variance of the responses for regression and the sum of test statistics (see splitrule) for survival.

In my case, I trained a regression forest. Here is a reproducible example including all feature importance measures offered by ranger:


## Estimate the same model with the three different importance measures offered by ranger
rg.iris_1 <- ranger(Sepal.Width ~ ., data = iris, importance = 'impurity')
rg.iris_2 <- ranger(Sepal.Width ~ ., data = iris, importance = 'impurity_corrected')
rg.iris_3 <- ranger(Sepal.Width ~ ., data = iris, importance = 'permutation')

## Store the importance measures in a table
varimp_table <- data.frame(impurity = rg.iris_1$variable.importance,
                               impurity_corrected = rg.iris_2$variable.importance,
                               perumtation = rg.iris_3$variable.importance)

This gives the following table:

enter image description here

And here are my questions:

  1. How can I interpret the three columns of this table?
  2. Are there any papers explaining what is meant by the different approaches?
  3. What are the pro's and con's of each measure?


After trying to make sense of the code on github, this seems to be the part where the variable importance is calculated in the case of the given example:

double decrease = sum_left * sum_left / (double) n_left + sum_right * sum_right / (double) n_right;

and for example, sum_right seems to be defined here:

for (size_t pos = start_pos[nodeID]; pos < end_pos[nodeID]; ++pos) {
      size_t sampleID = sampleIDs[pos];
      double response = data->get_y(sampleID, 0);
      double value = data->get_x(sampleID, varID);
      size_t factorID = floor(value) - 1;

      // If in right child, count
      // In right child, if bitwise splitID at position factorID is 1
      if ((splitID & (1ULL << factorID))) {
        sum_right += response;

I never learned C++, but this seems as if the squared response is averaged and not the response variance, as it is stated in the description of the package. This wouldn't really make sense, though... would it?

Please help!


1 Answer 1


Here are at least some links that might help:

On your additional question, squared response and variance is actually equivalent in optimization since the mean's cancel out.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.