1
$\begingroup$

I have trouble understanding the exact meaning of the feature importance scores in caret for RF regression. As you know there are many potential importance measures for RF. However, there is no clear indication which one is used.

Here is a toy example:

data(iris)

y_train = iris['Sepal.Length']
X_train = iris[2:4]

mdl_rf_inner <- caret::train(X_train, y_train$Sepal.Length, method = "rf",
                             preProcess = c("center", "scale"),
                             ntrees = 1000, importance = T)

feat_imp_2 <- caret::varImp(mdl_rf_inner, scale=F)

Resulting in:

rf variable importance

             Overall
Petal.Length   48.51
Sepal.Width    23.67
Petal.Width    17.15

Please keep in mind that I am predicting sepal length, so despite using iris data it is a regression problem. I read the docs and there is no clear indication as to which variable importance is being calculated (Gini-impurity decrease?, mse decrease?, permuation importance?, out of bag?, etc., etc.).

To further complicate things, the train function also has the importance = T argument, which doesn't really seem to serve a clear purpose when using varImp(). Is that correct?

I would greatly appreciate your insights on this.

Best wishes!

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to CV. No idea why someone downvoted a new person without the grace of a comment explaining why, but I'm sorry they did that. This is a decent question, and it should get a decent answer. I would bust out something like ranger, because it has very clearly articulated importance, and set up the same style of forest look for alignment with each of the importance types. The iris data is small, relatively speaking, so you shouldn't get much run-to-run variation. Best of luck. $\endgroup$ Dec 22, 2020 at 13:41
  • $\begingroup$ Also, you don't preprocess the class into a factor, so it might be treating it as continuous not discrete. $\endgroup$ Dec 22, 2020 at 13:49

1 Answer 1

1
$\begingroup$

This explanation might be what you missed.

If there is no model-specific way to estimate importance (or the argument useModel = FALSE is used in varImp) the importance of each predictor is evaluated individually using a “filter” approach.

For classification, ROC curve analysis is conducted on each predictor. For two class problems, a series of cutoffs is applied to the predictor data to predict the class. The sensitivity and specificity are computed for each cutoff and the ROC curve is computed. The trapezoidal rule is used to compute the area under the ROC curve. This area is used as the measure of variable importance. For multi-class outcomes, the problem is decomposed into all pair-wise problems and the area under the curve is calculated for each class pair (i.e. class 1 vs. class 2, class 2 vs. class 3 etc.). For a specific class, the maximum area under the curve across the relevant pair-wise AUC’s is used as the variable importance measure.

For regression, the relationship between each predictor and the outcome is evaluated. An argument, nonpara, is used to pick the model fitting technique. When nonpara = FALSE, a linear model is fit and the absolute value of the t-value for the slope of the predictor is used. Otherwise, a loess smoother is fit between the outcome and the predictor. The R2 statistic is calculated for this model against the intercept only null model. This number is returned as a relative measure of variable importance.

$\endgroup$

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.