You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-13Lines changed: 10 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,20 +15,18 @@
15
15
16
16
The package contains three functions to crunch SHAP values:
17
17
18
-
-**`permshap()`**: Permutation SHAP algorithm of [1]. Recommended for models with up to 8 features, or if you don't trust Kernel SHAP. Both exact and sampling versions are available.
19
-
-**`kernelshap()`**: Kernel SHAP algorithm of [2] and [3]. Recommended for models with more than 8 features. Both exact and (pseudo-exact) sampling versions are available.
18
+
-**`permshap()`**: Permutation SHAP algorithm of [1]. Both exact and sampling versions are available.
19
+
-**`kernelshap()`**: Kernel SHAP algorithm of [2] and [3]. Both exact and (pseudo-exact) sampling versions are available.
20
20
-**`additive_shap()`**: For *additive models* fitted via `lm()`, `glm()`, `mgcv::gam()`, `mgcv::bam()`, `gam::gam()`, `survival::coxph()`, or `survival::survreg()`. Exponentially faster than the model-agnostic options above, and recommended if possible.
21
21
22
-
To explain your model, select an explanation dataset `X` (up to 1000 rows from the training data, feature columns only) and apply the recommended function. Use {shapviz} to visualize the resulting SHAP values.
22
+
To explain your model, select an explanation dataset `X` (up to 1000 rows from the training data, feature columns only). Use {shapviz} to visualize the resulting SHAP values.
23
23
24
24
**Remarks to `permshap()` and `kernelshap()`**
25
25
26
26
- Both algorithms need a representative background data `bg_X` to calculate marginal means (up to 500 rows from the training data). In cases with a natural "off" value (like MNIST digits), this can also be a single row with all values set to the off value. If unspecified, 200 rows are randomly sampled from `X`.
27
-
- Exact Kernel SHAP is an approximation to exact permutation SHAP. Since exact calculations are usually sufficiently fast for up to eight features, we recommend `permshap()` in this case. With more features, `kernelshap()` switches to a comparably fast, almost exact algorithm with faster convergence than the sampling version of permutation SHAP.
28
-
That is why we recommend `kernelshap()` in this case.
29
-
- For models with interactions of order up to two, SHAP values of permutation SHAP and Kernel SHAP agree,
30
-
and the implemented sampling versions provide the same results as the exact versions.
31
-
In the presence of interactions of order three or higher, this is no longer the case.
27
+
- Exact Kernel SHAP gives identical results as exact permutation SHAP. Both algorithms are fast up to 8 features.
28
+
With more features, `kernelshap()` switches to an almost exact algorithm with faster convergence than the sampling version of permutation SHAP.
29
+
- For models with interactions of order up to two, the sampling versions provide the same results as the exact versions.
32
30
- For additive models, `permshap()` and `kernelshap()` give the same results as `additive_shap`
33
31
as long as the full training data would be used as background data.
34
32
@@ -89,13 +87,12 @@ ps
89
87
[1,] 1.19132470.09005467-0.134307200.000682593
90
88
[2,] -0.4931989-0.117247730.098689210.028563613
91
89
92
-
# Kernel SHAP gives very slightly different values because the model contains
0 commit comments