Get a data frame with various measures of importance of variables in a random forest
measure_importance(forest, mean_sample = "top_trees", measures = NULL)
| forest | A random forest produced by the function randomForest with option localImp = TRUE |
|---|---|
| mean_sample | The sample of trees on which mean minimal depth is calculated, possible values are "all_trees", "top_trees", "relevant_trees" |
| measures | A vector of names of importance measures to be calculated - if equal to NULL then all are calculated;
if "p_value" is to be calculated then "no_of_nodes" will be too. Suitable measures for |
A data frame with rows corresponding to variables and columns to various measures of importance of variables
forest <- randomForest::randomForest(Species ~ ., data = iris, localImp = TRUE, ntree = 300) measure_importance(forest)#> variable mean_min_depth no_of_nodes accuracy_decrease gini_decrease #> 1 Petal.Length 1.1114865 749 0.298860983 42.010102 #> 2 Petal.Width 0.9932432 775 0.310185955 43.803248 #> 3 Sepal.Length 2.0128041 493 0.033657157 11.235496 #> 4 Sepal.Width 3.2915203 356 0.007638947 2.196532 #> no_of_trees times_a_root p_value #> 1 296 116 3.594621e-13 #> 2 296 124 3.550723e-17 #> 3 265 60 9.999994e-01 #> 4 215 0 1.000000e+00