plot_interaction {treeshap}R Documentation

SHAP Interaction value plot

Description

This function plots SHAP Interaction value for two variables depending on the value of the first variable. Value of the second variable is marked with the color.

Usage

plot_interaction(
  treeshap,
  var1,
  var2,
  title = "SHAP Interaction Value Plot",
  subtitle = ""
)

Arguments

treeshap

A treeshap object produced with treeshap(interactions = TRUE) function. treeshap.object.

var1

name or index of the first variable - plotted on x axis.

var2

name or index of the second variable - marked with color.

title

the plot's title, by default 'SHAP Interaction Value Plot'.

subtitle

the plot's subtitle. By default no subtitle.

Value

a ggplot2 object

See Also

treeshap for calculation of SHAP Interaction values

plot_contribution, plot_feature_importance, plot_feature_dependence

Examples


data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
target <- fifa20$target
param2 <- list(objective = "reg:squarederror", max_depth = 5)
xgb_model2 <- xgboost::xgboost(as.matrix(data), params = param2, label = target, nrounds = 10)
unified_model2 <- xgboost.unify(xgb_model2, data)
inters <- treeshap(unified_model2, as.matrix(data[1:50, ]), interactions = TRUE)
plot_interaction(inters, "dribbling", "defending")


[Package treeshap version 0.3.1 Index]