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
{kernelshap} can deal with almost any situation. We will show some of the flexibility here. The first two examples require you to run at least up to Step 2 of the "Basic Usage" code.
119
119
120
+
### Parallel computing
121
+
122
+
Parallel computing is supported via {foreach}. Note that this does not work with all models, and that there is no progress bar.
123
+
124
+
On Windows, sometimes not all packages or global objects are passed to the parallel sessions. Often, this can be fixed via `parallel_args`, see the generalized additive model below.
125
+
126
+
```r
127
+
library(doFuture)
128
+
library(mgcv)
129
+
130
+
registerDoFuture()
131
+
plan(multisession, workers=4) # Windows
132
+
# plan(multicore, workers = 4) # Linux, macOS, Solaris
# Because there are no interactions of order above 2, Kernel SHAP gives the same:
149
+
system.time( # 27 s non-parallel
150
+
ks<- kernelshap(fit, X, bg_X=bg_X)
151
+
)
152
+
all.equal(ps$S, ks$S)
153
+
# [1] TRUE
154
+
155
+
# Now the usual plots:
156
+
sv<- shapviz(ps)
157
+
sv_importance(sv, kind="bee")
158
+
sv_dependence(sv, xvars)
159
+
```
160
+
161
+

162
+
163
+

164
+
120
165
### Taylored predict()
121
166
122
167
In this {keras} example, we show how to use a tailored `predict()` function that complies with
@@ -170,41 +215,6 @@ sv_dependence(ps, xvars)
170
215
171
216

172
217
173
-
### Parallel computing
174
-
175
-
Parallel computing is supported via {foreach}. Note that this does not work with all models, and that there is no progress bar.
176
-
177
-
On Windows, sometimes not all packages or global objects are passed to the parallel sessions. In this case, the necessary instructions to {foreach} can be specified through a named list via `parallel_args`, see the following example.
178
-
179
-
```r
180
-
library(doFuture)
181
-
library(mgcv)
182
-
183
-
registerDoFuture()
184
-
plan(multisession, workers=4) # Windows
185
-
# plan(multicore, workers = 4) # Linux, macOS, Solaris
0 commit comments