Skip to content

Commit

Permalink
Adapt README
Browse files Browse the repository at this point in the history
  • Loading branch information
mayer79 committed May 25, 2024
1 parent 88cb3c4 commit 3e5c75d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The package contains two workhorses to calculate SHAP values for *any* model:
- `kernelshap()`: Kernel SHAP algorithm of [2] and [3]. By default, exact Kernel SHAP is used for up to $p=8$ features, and an almost exact hybrid algorithm otherwise.

Furthermore, the function `additive_shap()` produces SHAP values for additive models fitted via `lm()`, `glm()`, `mgcv::gam()`, `mgcv::bam()`, `gam::gam()`,
`survival::coxph()`, or `survival::survreg()`.
`survival::coxph()`, or `survival::survreg()`. It is exponentially faster than `permshap()` and `kernelshap()` and provides identical results.

### Kernel SHAP or permutation SHAP?

Expand All @@ -41,6 +41,7 @@ If the training data is small, use the full training data. In cases with a natur
- Factor-valued predictions are automatically turned into one-hot-encoded columns.
- Case weights are supported via the argument `bg_w`.
- By changing the defaults in `kernelshap()`, the iterative pure sampling approach in [3] can be enforced.
- The `additive_shap()` explainer is easier to use: Only the model and `X` are required.

## Installation

Expand Down Expand Up @@ -218,6 +219,18 @@ sv_dependence(ps, xvars)

![](man/figures/README-nn-dep.svg)

### Additive SHAP

The additive explainer extracts the additive contribution of each feature from a model of suitable class.

```r
fit <- lm(log(price) ~ log(carat) + color + clarity + cut, data = diamonds)
shap_values <- additive_shap(fit, diamonds) |>
shapviz()
sv_importance(shap_values)
sv_dependence(shap_values, v = "carat", color_var = NULL)
```

### Multi-output models

{kernelshap} supports multivariate predictions like:
Expand Down

0 comments on commit 3e5c75d

Please sign in to comment.