Put feature importance tables to a model rack
Source:R/make_feature_importance.R
rack_put_feature_importance.RdGiven a model rack, calculate feature importances for each
model using shelf_make_feature_importance() and put results to a column
called "feature_importance".
Examples
library(dplyr)
library(tidyr)
rack_extended <- rack_put_feature_importance(example_seg_rack)
# unnest results into one dataframe
rack_extended %>%
select(model_name, feature_importance) %>%
unnest(feature_importance)
#> # A tibble: 162 × 4
#> model_name feature label importance
#> <fct> <chr> <chr> <dbl>
#> 1 nmf_3 m2_1_5 I feel like I’m too much of a burden on the pe… 0.214
#> 2 nmf_3 m2_6_54 I usually pay the minimum monthly payment on m… 0.200
#> 3 nmf_3 m2_5_45 I just buy things that I might need and then r… 0.181
#> 4 nmf_3 m2_6_56 Credit cards are designed to hurt card holders. 0.166
#> 5 nmf_3 m2_4_32 I feel confident about my ability to manage m… 0.132
#> 6 nmf_3 m2_4_30 I’m a saver not a spender 0.111
#> 7 nmf_3 m2_6_48 I spend more than I otherwise would when payin… 0.105
#> 8 nmf_3 m2_1_1 Achieving personal success is most important t… 0
#> 9 nmf_3 m2_1_2 I tend to accomplish small life goals at a tim… 0
#> 10 nmf_3 m2_1_3 I have a specific role model that has had a si… 0
#> # ℹ 152 more rows