Learn R Programming

autostats (version 0.4.2)

tidy_shap: tidy shap

Description

plot and summarize shapley values from an xgboost model

Usage

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

Value

list

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.

Details

returns a list with the following entries

shap_tbl

: table of shaply values

shaps_long

: long table of feature and 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