Configure per-case Shapley additive explanations for explain().
setup_SHAP(
estimator = "auto",
perturbation = NULL,
scale = NULL,
background_n = NULL,
n_coalitions = NULL,
approach = NULL,
seed = NULL
)SHAPConfig object.
Character {"auto", "exact", "kernel"}: Which estimator to use.
Optional Character {"interventional", "conditional"}: Value function. NULL uses the resolved estimator's documented default.
Optional Character {"margin", "probability"}: Scale the contributions are additive on. NULL sets it from the outcome type.
Optional Integer [1, Inf): Cases to subsample from the background data. NULL uses all of it.
Optional Integer [2, Inf): Most feature subsets the kernel estimator evaluates. NULL lets the backend decide.
Optional Character {"empirical", "gaussian", "copula", "ctree", "vaeac", "categorical", "timeseries"}: Conditional-distribution estimator used by the kernel estimator.
Optional Integer [0, Inf): Random seed.
EDG
Three choices here define what is computed, and each is recorded on the returned explanation, so explanations computed differently are told apart.
perturbation is the question being asked. "interventional" breaks the
dependence between features, attributing to what the model uses: a feature
the model ignores gets zero even if it predicts the outcome perfectly.
"conditional" respects the joint distribution, attributing to what the
case's features carry information about, so a correlated proxy for a used
feature receives credit. The first describes the model's computation; the
second describes the case.
scale decides whether the contributions add up. They are additive on
the scale they are computed on. For regression that is the outcome and there
is nothing to choose. For classification the model's additive scale is the
margin, and probability is a nonlinear transform of it, so contributions on
the probability scale do not sum to the predicted probability.
estimator defaults to "auto", which uses the exact
estimator wherever the algorithm has one and the model-agnostic kernel
estimator otherwise; explanation_traits() reports which applies where.
approach and n_coalitions apply only to the kernel estimator, and
approach only when perturbation is "conditional" -- the interventional
answer is not one of several conditional estimators, it is the absence of
conditioning.
Setting either therefore requires estimator = "kernel" rather than
"auto", even for an algorithm "auto" would send to the kernel estimator
anyway. Tuning an estimator is a decision to use it, and the alternative --
accepting settings that a resolved exact estimator would then ignore --
would drop them silently.
setup_SHAP()
setup_SHAP(perturbation = "conditional")
setup_SHAP(estimator = "kernel", perturbation = "conditional", approach = "ctree")
Run the code above in your browser using DataLab