8.41 Variable importance

The broomstick package (https://github.com/njtierney/broomstick/) enables the analyst to extract the decision tree variable importance from the fitted model.

library(forcats)
broomstick::tidy(class_tree_final_fit$fit) %>% 
     mutate(variable = variable %>% as_factor() %>% fct_rev()) %>% 
     ggplot(aes(y = variable, x = importance)) + 
     geom_col(fill = "steelblue")