|
6 | 6 | #' |
7 | 7 | #' By default, for up to p=8 features, exact SHAP values are returned |
8 | 8 | #' (exact with respect to the selected background data). |
9 | | -#' |
10 | 9 | #' Otherwise, the sampling process iterates until the resulting values |
11 | 10 | #' are sufficiently precise, and standard errors are provided. |
12 | 11 | #' |
| 12 | +#' @details |
13 | 13 | #' During each iteration, the algorithm cycles twice through a random permutation: |
14 | 14 | #' It starts with all feature components "turned on" (i.e., taking them |
15 | 15 | #' from the observation to be explained), then gradually turning off components |
16 | | -#' according to the permutation (i.e., marginalizing them over the background data). |
| 16 | +#' according to the permutation. |
17 | 17 | #' When all components are turned off, the algorithm - one by one - turns the components |
18 | 18 | #' back on, until all components are turned on again. This antithetic scheme allows to |
19 | | -#' evaluate Shapley's formula 2p times with each permutation, using a total of |
20 | | -#' 2p + 1 evaluations of marginal means. |
| 19 | +#' evaluate Shapley's formula twice per feature using a single permutation and a total |
| 20 | +#' of 2p disjoint evaluations of the contribution function. |
21 | 21 | #' |
22 | 22 | #' For models with interactions up to order two, one can show that |
23 | | -#' even a single iteration provides exact SHAP values (with respect to the |
24 | | -#' given background dataset). |
| 23 | +#' even a single iteration provides exact SHAP values for all features |
| 24 | +#' (with respect to the given background dataset). |
25 | 25 | #' |
26 | 26 | #' The Python implementation "shap" uses a similar approach, but without |
27 | | -#' providing standard errors, and without early stopping. To mimic its behavior, |
28 | | -#' we would need to set `max_iter = p` in R, and `max_eval = (2*p+1)*p` in Python. |
| 27 | +#' providing standard errors, and without early stopping. |
29 | 28 | #' |
30 | 29 | #' For faster convergence, we use balanced permutations in the sense that |
31 | 30 | #' p subsequent permutations each start with a different feature. |
32 | 31 | #' Furthermore, the 2p on-off vectors with sum <=1 or >=p-1 are evaluated only once, |
33 | | -#' similar to the degree 1 hybrid in [kernelshap()] (but covering less weight). |
| 32 | +#' similar to the degree 1 hybrid in [kernelshap()]. |
34 | 33 | #' |
35 | | -#' @param exact If `TRUE`, the algorithm produces exact SHAP values |
36 | | -#' with respect to the background data. |
37 | | -#' The default is `TRUE` for up to eight features, and `FALSE` otherwise. |
38 | | -#' @param low_memory If `FALSE` (default up to p = 15), the algorithm evaluates p |
39 | | -#' predictions together, reducing the number of calls to `predict()`. |
| 34 | +#' @param low_memory If `FALSE` (default up to p = 15), the algorithm does p |
| 35 | +#' iterations in one chunk, evaluating Shapley's formula 2p^2 times. |
| 36 | +#' For models with interactions up to order two, you can set this to `TRUE` |
| 37 | +#' to save time. |
40 | 38 | #' @inheritParams kernelshap |
41 | 39 | #' @returns |
42 | 40 | #' An object of class "kernelshap" with the following components: |
|
0 commit comments