
tidy up dataframe containing model feature importance
Source:R/alluvial_model_response.R
tidy_imp.Rd
returns dataframe with exactly two columns, vars and imp and aggregates dummy encoded variables. Helper function called by all functions that take an imp parameter. Can be called manually if formula for aggregating dummy encoded variables must be modified.
Examples
# randomforest
df = mtcars2[, ! names(mtcars2) %in% 'ids' ]
m = randomForest::randomForest( disp ~ ., df)
imp = m$importance
tidy_imp(imp, df)
#> # A tibble: 10 × 2
#> vars imp
#> <chr> <dbl>
#> 1 cyl 96402.
#> 2 mpg 89923.
#> 3 hp 77633.
#> 4 wt 71970.
#> 5 drat 46440.
#> 6 gear 21548.
#> 7 qsec 20524.
#> 8 vs 15734.
#> 9 carb 8570.
#> 10 am 5091.