plot_vi: Plot variable importance

View source: R/plot_vi.R

plot_viR Documentation

Plot variable importance

Description

Plot variable importance scores for the predictors in a model.

Usage

plot_vi(vi)

Arguments

vi

Data frame containing the variable importance scores as returned by get_vi.

Value

ggplot object showing the variable importance scores in vi.

Examples

## 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)

henckr/maidrr documentation built on July 27, 2023, 3:17 p.m.