get_vi: Calculate variable importance

View source: R/get_vi.R

get_viR Documentation

Calculate variable importance

Description

Compute variable importance scores for the predictors in a model. Note that get_vi is a simple wrapper for vip::vi.

Usage

get_vi(mfit, ...)

Arguments

mfit

Fitted model object (e.g., a "gbm" or "randomForest" object).

...

Additional optional arguments to be passed onto vip::vi.

Value

Tidy data frame (i.e., a "tibble" object) with two columns: Variable and Importance.

See Also

vi and https://CRAN.R-project.org/package=vip.

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
gbm_fit %>% get_vi(scale = TRUE)

## End(Not run)

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