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.
By default, the feature on the color scale is selected via SHAP interactions
(if available) or an interaction heuristic, see potential_interactions()
.
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,
ih_nbins = NULL,
ih_color_num = TRUE,
ih_scale = FALSE,
ih_adjusted = 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,
ih_nbins = NULL,
ih_color_num = TRUE,
ih_scale = FALSE,
ih_adjusted = 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 |
ih_nbins , ih_color_num , ih_scale , ih_adjusted |
Interaction heuristic (ih)
parameters used to select the color variable, see |
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()
dtrain <- xgboost::xgb.DMatrix(
data.matrix(iris[, -1]), label = iris[, 1], nthread = 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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.