View source: R/plot_interaction.R
plot_interaction | R Documentation |
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.
plot_interaction(
treeshap,
var1,
var2,
title = "SHAP Interaction Value Plot",
subtitle = ""
)
treeshap |
A treeshap object produced with |
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 |
subtitle |
the plot's subtitle. By default no subtitle. |
a ggplot2
object
treeshap
for calculation of SHAP Interaction values
plot_contribution
, plot_feature_importance
, plot_feature_dependence
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.