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: vignettes/projpred.Rmd
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,8 @@ For this final `cv_varsel()` run (with `validate_search = TRUE`, as recommended)
189
189
In practice, we recommend using either the default of `cv_method = "LOO"` (possibly subsampled, see argument `nloo` of `cv_varsel()`) or a larger value for `K` if this is possible in terms of computation time.
190
190
Here, we also perform the $K$ reference model refits outside of `cv_varsel()`.
191
191
Although not strictly necessary here, this is helpful in practice because often, `cv_varsel()` needs to be re-run multiple times in order to try out different argument settings.
192
-
We also illustrate how **projpred**'s CV (i.e., the CV comprising search and performance evaluation, after refitting the reference model $K$ times) can be parallelized, even though this is of little use here (we have only `K = 2` folds and the fold-wise searches and performance evaluations are quite fast, so the parallelization overhead eats up any runtime improvements).
192
+
We also show how **projpred**'s CV (i.e., the CV comprising search and performance evaluation, after refitting the reference model $K$ times) can be parallelized (though we disable it here for vignette building).
193
+
In practice, parallelization is of little use with only `K = 2` folds and fast fold-wise operations, as the parallelization overhead eats up any runtime improvements.
193
194
Note that for this final `cv_varsel()` run, we cannot make use of `cv_varsel.vsel()` (by applying `cv_varsel()` to `cvvs_fast` or `cvvs_fast_refit` instead of `refm_obj`) because of the change in `nterms_max` (here: 9, for `cvvs_fast` and `cvvs_fast_refit`: 20).
194
195
```{r cv_varsel, message=FALSE}
195
196
# Refit the reference model K times:
@@ -200,7 +201,11 @@ cv_fits <- run_cvfun(
200
201
###
201
202
)
202
203
# For running projpred's CV in parallel (see cv_varsel()'s argument `parallel`):
203
-
doParallel::registerDoParallel(ncores)
204
+
# Note: Parallel processing is disabled during package building to avoid issues
205
+
use_parallel <- FALSE # Set to TRUE for actual parallel processing
206
+
if (use_parallel) {
207
+
doParallel::registerDoParallel(ncores)
208
+
}
204
209
# Final cv_varsel() run:
205
210
cvvs <- cv_varsel(
206
211
refm_obj,
@@ -211,14 +216,16 @@ cvvs <- cv_varsel(
211
216
nclusters_pred = 20,
212
217
###
213
218
nterms_max = 9,
214
-
parallel = TRUE,
219
+
parallel = use_parallel,
215
220
### In interactive use, we recommend not to deactivate the verbose mode:
216
221
verbose = 0
217
222
###
218
223
)
219
224
# Tear down the CV parallelization setup:
220
-
doParallel::stopImplicitCluster()
221
-
foreach::registerDoSEQ()
225
+
if (use_parallel) {
226
+
doParallel::stopImplicitCluster()
227
+
foreach::registerDoSEQ()
228
+
}
222
229
```
223
230
224
231
#### Predictive performance plot from final `cv_varsel()` run {#plotfinal}
0 commit comments