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 60.7 #> 3 wt 60.6 #> 4 hp 44.9 #> 5 am 29.0 #> 6 vs 28.4 #> 7 gear 11.2 #> 8 carb 9.62 #> 9 drat 7.06
plot(vi)