vi_shap: SHAP-based variable importance

Description Usage Arguments Details Value

View source: R/vi_shap.R

Description

Compute SHAP-based VI scores for the predictors in a model. See details below.

Usage

1
2
3
4
vi_shap(object, ...)

## Default S3 method:
vi_shap(object, feature_names = NULL, train = NULL, ...)

Arguments

object

A fitted model object (e.g., a "randomForest" object).

...

Additional optional arguments to be passed on to explain.

feature_names

Character string giving the names of the predictor variables (i.e., features) of interest. If NULL (the default) then the internal 'get_feature_names()' function will be called to try and extract them automatically. It is good practice to always specify this argument.

train

A matrix-like R object (e.g., a data frame or matrix) containing the training data. If NULL (the default) then the internal 'get_training_data()' function will be called to try and extract it automatically. It is good practice to always specify this argument.

Details

This approach to computing VI scores is based on the mean absolute value of the SHAP values for each feature; see, for example, https://github.com/slundberg/shap and the references therein.

Strumbelj, E., and Kononenko, I. Explaining prediction models and individual predictions with feature contributions. Knowledge and information systems 41.3 (2014): 647-665.

Value

A tidy data frame (i.e., a "tibble" object) with two columns, Variable and Importance, containing the variable name and its associated importance score, respectively.


vip documentation built on Dec. 17, 2020, 5:08 p.m.