plot_vi | R Documentation |
Plot variable importance scores for the predictors in a model.
plot_vi(vi)
vi |
Data frame containing the variable importance scores as returned by
|
ggplot object showing the variable importance scores in vi
.
## Not run:
data('mtpl_be')
features <- setdiff(names(mtpl_be), c('id', 'nclaims', 'expo', 'long', 'lat'))
set.seed(12345)
gbm_fit <- gbm::gbm(as.formula(paste('nclaims ~',
paste(features, collapse = ' + '))),
distribution = 'poisson',
data = mtpl_be,
n.trees = 50,
interaction.depth = 3,
shrinkage = 0.1)
gbm_fit %>% get_vi %>% plot_vi
gbm_fit %>% get_vi(scale = TRUE) %>% plot_vi
gbm_fit %>% get_vi %>% dplyr::mutate(Importance = Importance / 100) %>% plot_vi + scale_y_continuous(labels = scales::percent)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.