
Variable importance as measured by mean absolute SHAP value.
Source:R/SHAP_funcs.R
shap.importance.RdVariable importance as measured by mean absolute SHAP value.
Arguments
- data_long
a long format data of SHAP values from
shap.prep- names_only
If
TRUE, returns variable names only.- top_n
How many variables to be returned?
Value
returns data.table with average absolute SHAP
values per variable, sorted in decreasing order of importance.
Examples
shap.importance(shap_long_iris)
#> Key: <variable>
#> variable mean_abs_shap
#> <fctr> <num>
#> 1: Petal.Length 0.62935975
#> 2: Petal.Width 0.21664035
#> 3: Sepal.Length 0.02910357
#> 4: Sepal.Width 0.00000000
shap.importance(shap_long_iris, names_only = 1)
#> Key: <variable>
#> variable mean_abs_shap
#> <fctr> <num>
#> 1: Petal.Length 0.62935975
#> 2: Petal.Width 0.21664035
#> 3: Sepal.Length 0.02910357
#> 4: Sepal.Width 0.00000000