| shap_long | R Documentation |
The long form a beeswarm reads: a point per case per feature, positioned by its contribution and colored by the value the feature took.
shap_long(x, newdata, class = NULL)
x |
|
newdata |
tabular data: The cases |
class |
Optional Character: Which class's contributions. NULL takes the first. |
Shaped here, for the reason shap_case() gives.
data.table with columns case, feature, value, numeric_value
and contribution. numeric_value is NA for a feature that is not numeric,
which is what a color scale needs to skip it.
EDG
x <- data.frame(age = rnorm(100), bmi = rnorm(100))
x[["y"]] <- x[["age"]] * 2 + rnorm(100, sd = 0.3)
mod <- train(x, hyperparameters = setup_GLM(), verbosity = 0L)
contributions <- explain(
mod,
x[, c("age", "bmi")],
background = x[, c("age", "bmi")],
verbosity = 0L
)
head(shap_long(contributions, x[, c("age", "bmi")]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.