Learn R Programming

rtemis (version 1.4.3)

setup_SHAP: Setup SHAP Explanation

Description

Configure per-case Shapley additive explanations for explain().

Usage

setup_SHAP(
  estimator = "auto",
  perturbation = NULL,
  scale = NULL,
  background_n = NULL,
  n_coalitions = NULL,
  approach = NULL,
  seed = NULL
)

Value

SHAPConfig object.

Arguments

estimator

Character {"auto", "exact", "kernel"}: Which estimator to use.

perturbation

Optional Character {"interventional", "conditional"}: Value function. NULL uses the resolved estimator's documented default.

scale

Optional Character {"margin", "probability"}: Scale the contributions are additive on. NULL sets it from the outcome type.

background_n

Optional Integer [1, Inf): Cases to subsample from the background data. NULL uses all of it.

n_coalitions

Optional Integer [2, Inf): Most feature subsets the kernel estimator evaluates. NULL lets the backend decide.

approach

Optional Character {"empirical", "gaussian", "copula", "ctree", "vaeac", "categorical", "timeseries"}: Conditional-distribution estimator used by the kernel estimator.

seed

Optional Integer [0, Inf): Random seed.

Author

EDG

Details

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.

Examples

Run this code
setup_SHAP()
setup_SHAP(perturbation = "conditional")
setup_SHAP(estimator = "kernel", perturbation = "conditional", approach = "ctree")

Run the code above in your browser using DataLab