Get variable importances

get_variable_importance(models, remove_zeros = TRUE, top_n)

Arguments

models

model_list object

remove_zeros

Remove features with zero variable importance? Default is TRUE

top_n

Integer: How many variables to return? The top_n most important variables be returned. If missing (default), all variables are returned

Value

Data frame of variables and their importance for predictive power

Details

Some algorithms provide variable importance, others don't. The best-performing model that offers variable importance will be used.

See also

Examples

m <- machine_learn(mtcars, outcome = mpg, models = "rf", tune = FALSE)
#> Training new data prep recipe...
#> #> mpg looks numeric, so training regression algorithms.
#> #> After data processing, models are being trained on 10 features with 32 observations. #> Based on n_folds = 5 and hyperparameter settings, the following number of models will be trained: 5 rf's
#> Training at fixed values: Random Forest
#> #> *** Models successfully trained. The model object contains the training data minus ignored ID columns. *** #> *** If there was PHI in training data, normal PHI protocols apply to the model object. ***
(vi <- get_variable_importance(m))
#> # A tibble: 9 x 2 #> variable importance #> * <chr> <dbl> #> 1 cyl 100 #> 2 disp 81.2 #> 3 wt 70.2 #> 4 hp 51.1 #> 5 vs 45.2 #> 6 am 25.2 #> 7 carb 12.2 #> 8 drat 12.1 #> 9 gear 8.71
plot(vi)