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
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,30 +2,30 @@
2
2
3
3
## Introduction
4
4
5
-
SHAP values [1]decompose model predictions into additive contributions of the features in a fair way. A model agnostic approach is called Kernel SHAP, introduced in [1], and investigated in detail in [2].
5
+
SHAP values (Lundberg and Lee, 2017) decompose model predictions into additive contributions of the features in a fair way. A model agnostic approach is called Kernel SHAP, introduced in Lundberg and Lee (2017), and investigated in detail in Covert and Lee (2021).
6
6
7
-
The "kernelshap" package implements the Kernel SHAP Algorithm 1 described in the supplement of [2]. An advantage of their algorithm is that SHAP values are supplemented by standard errors. Furthermore, convergence can be monitored and controlled.
7
+
The "kernelshap" package implements the Kernel SHAP Algorithm 1 described in the supplement of Covert and Lee (2021). An advantage of their algorithm is that SHAP values are supplemented by standard errors. Furthermore, convergence can be monitored and controlled.
8
8
9
-
The main function,`kernelshap()`, requires three key arguments:
9
+
The main function `kernelshap()` has three key arguments:
10
10
11
11
-`X`: A matrix or data.frame of rows to be explained. Important: The columns should only represent model features, not the response.
12
12
-`pred_fun`: A function that takes a data structure like `X` and provides one numeric prediction per row. Some examples:
13
13
-`lm()`: `function(X) predict(fit, X)`
14
14
-`glm()`: `function(X) predict(fit, X)` (link scale) or
15
15
-`glm()`: `function(X) predict(fit, X, type = "response")` (response scale)
-`bg_X`: The background data used to integrate out "switched off" features. It should have the same column structure as `X`. A good size is around $50-200$ rows.
21
21
22
22
**Remarks**
23
23
24
-
-Visualizations: To visualize the result, you can use R package "shapviz".
25
-
- Meta-learners: "kernelshap" plays well together with packages like "caret" and "mlr3".
26
-
- Case weights: Passing `bg_w` allows to respect case weights of the background data.
27
-
- Classification: If your model provides multiple outputs per observation, e.g., for a classification task, just pass the probabilities of one class via `pred_fun`. This is necessary since `kernelshap()` requires one numeric prediction per row.
28
-
- Speed: If `X` and `bg_X` are matrices, the algorithm will often run much faster.
24
+
-*Visualization:* To visualize the result, you can use R package "shapviz".
25
+
-*Meta-learners:* "kernelshap" plays well together with packages like "caret" and "mlr3".
26
+
-*Case weights:* Passing `bg_w` allows to weight background data.
27
+
-*Classification:*`kernelshap()` requires one numeric prediction per row. Thus, the prediction function should provide probabilities only of a selected class.
28
+
-*Speed:* If `X` and `bg_X` are matrices, the algorithm can runs faster. The faster the prediction function, the more this matters.
This is the inital release of the Kernel SHAP algorithm as described in the article
4
-
http://proceedings.mlr.press/v130/covert21a of Covert and Lee 2021.
4
+
http://proceedings.mlr.press/v130/covert21a of Covert and Lee 2021. Along with SHAP values for any type of regression, the algorithm provides standard errors of the SHAP values. Furthermore, convergence is monitored.
5
5
6
6
## Checks
7
7
8
-
- check_win_devel() -> Ok
9
-
- check(manual = TRUE, cran = TRUE) -> usual warning on pdf compression.
0 commit comments