View source: R/sv_dependence.R
sv_dependence | R Documentation |
Scatterplot of the SHAP values of a feature against its feature values.
If SHAP interaction values are available, setting interactions = TRUE
allows
to focus on pure interaction effects (multiplied by two) or on pure main effects.
sv_dependence(object, ...)
## Default S3 method:
sv_dependence(object, ...)
## S3 method for class 'shapviz'
sv_dependence(
object,
v,
color_var = "auto",
color = "#3b528b",
viridis_args = getOption("shapviz.viridis_args"),
jitter_width = NULL,
interactions = FALSE,
...
)
## S3 method for class 'mshapviz'
sv_dependence(
object,
v,
color_var = "auto",
color = "#3b528b",
viridis_args = getOption("shapviz.viridis_args"),
jitter_width = NULL,
interactions = FALSE,
...
)
object |
An object of class "(m)shapviz". |
... |
Arguments passed to |
v |
Column name of feature to be plotted. Can be a vector/list if |
color_var |
Feature name to be used on the color scale to investigate
interactions. The default ("auto") uses SHAP interaction values (if available),
or a heuristic to select the strongest interacting feature. Set to |
color |
Color to be used if |
viridis_args |
List of viridis color scale arguments, see
|
jitter_width |
The amount of horizontal jitter. The default ( |
interactions |
Should SHAP interaction values be plotted? Default is |
An object of class "ggplot" (or "patchwork") representing a dependence plot.
sv_dependence(default)
: Default method.
sv_dependence(shapviz)
: SHAP dependence plot for "shapviz" object.
sv_dependence(mshapviz)
: SHAP dependence plot for "mshapviz" object.
potential_interactions()
## Not run:
dtrain <- xgboost::xgb.DMatrix(data.matrix(iris[, -1]), label = iris[, 1])
fit <- xgboost::xgb.train(data = dtrain, nrounds = 10, nthread = 1)
x <- shapviz(fit, X_pred = dtrain, X = iris)
sv_dependence(x, "Petal.Length")
sv_dependence(x, "Petal.Length", color_var = "Species")
sv_dependence(x, "Petal.Length", color_var = NULL)
sv_dependence(x, c("Species", "Petal.Length"))
sv_dependence(x, "Petal.Width", color_var = c("Species", "Petal.Length"))
# SHAP interaction values/main effects
x2 <- shapviz(fit, X_pred = dtrain, X = iris, interactions = TRUE)
sv_dependence(x2, "Petal.Length", interactions = TRUE)
sv_dependence(
x2, c("Petal.Length", "Species"), color_var = NULL, interactions = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.