| shap_case | R Documentation |
The three things a per-case explanation is: where the prediction would have started, what each feature did to it, and where it ended.
shap_case(x, newdata, case = 1L, class = NULL)
x |
|
newdata |
tabular data: The cases |
case |
Integer or Character: Which case, by position or row name. |
class |
Optional Character: Which class's contributions. NULL takes the first, which is the only one for a regression or binary outcome. |
Shaped here, following session_timeline(): the
table is the shared input for rtemis.draw's chart and for rtemislive, so both
show the same thing, and it is useful on its own without either.
Features are ordered by the magnitude of their contribution, which is the order a waterfall reads in, and each carries the value it took for this case so the row reads "age = 62, +0.4".
List with steps (a data.table of feature, value and
contribution), baseline, predicted, case and class.
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
)
shap_case(contributions, x[, c("age", "bmi")], case = 1L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.