plot and summarize shapley values from an xgboost model

tidy_shap(model, newdata, form = NULL, ..., top_n = 12, aggregate = NULL)

Arguments

model

xgboost model

newdata

dataframe similar to model input

form

formula used for model

...

additional parameters for shapley value

top_n

top n features

aggregate

a character vector. Predictors containing the string will be aggregated, and renamed to that string.

Value

list

Details

returns a list with the following entries

shap_tbl

: table of shaply values

shap_summary

: table summarizing shapley values. Includes correlation between shaps and feature values.

swarmplot

: one plot showing the relation between shaps and features

scatterplots

: returns the top 9 most important features as determined by sum of absolute shapley values, as a facetted scatterplot of feature vs shap