@@ -354,12 +354,12 @@ Although not strictly necessary here, this is helpful in practice
354354because often,
355355[ ` cv_varsel() ` ] ( https://mc-stan.org/projpred/dev/reference/cv_varsel.md )
356356needs to be re-run multiple times in order to try out different argument
357- settings. We also illustrate how ** projpred** ’s CV (i.e., the CV
358- comprising search and performance evaluation, after refitting the
359- reference model \\ K\\ times) can be parallelized, even though this is of
360- little use here (we have only ` K = 2 ` folds and the fold-wise searches
361- and performance evaluations are quite fast, so the parallelization
362- overhead eats up any runtime improvements) . Note that for this final
357+ settings. We also show how ** projpred** ’s CV (i.e., the CV comprising
358+ search and performance evaluation, after refitting the reference model
359+ \\ K\\ times) can be parallelized ( though we disable it here for vignette
360+ building). In practice, parallelization is of little use with only
361+ ` K = 2 ` folds and fast fold-wise operations, as the parallelization
362+ overhead eats up any runtime improvements. Note that for this final
363363[ ` cv_varsel() ` ] ( https://mc-stan.org/projpred/dev/reference/cv_varsel.md )
364364run, we cannot make use of
365365[ ` cv_varsel.vsel() ` ] ( https://mc-stan.org/projpred/dev/reference/cv_varsel.md )
@@ -378,7 +378,11 @@ cv_fits <- run_cvfun(
378378 # ##
379379)
380380# For running projpred's CV in parallel (see cv_varsel()'s argument `parallel`):
381- doParallel :: registerDoParallel(ncores )
381+ # Note: Parallel processing is disabled during package building to avoid issues
382+ use_parallel <- FALSE # Set to TRUE for actual parallel processing
383+ if (use_parallel ) {
384+ doParallel :: registerDoParallel(ncores )
385+ }
382386# Final cv_varsel() run:
383387cvvs <- cv_varsel(
384388 refm_obj ,
@@ -389,14 +393,16 @@ cvvs <- cv_varsel(
389393 nclusters_pred = 20 ,
390394 # ##
391395 nterms_max = 9 ,
392- parallel = TRUE ,
396+ parallel = use_parallel ,
393397 # ## In interactive use, we recommend not to deactivate the verbose mode:
394398 verbose = 0
395399 # ##
396400)
397401# Tear down the CV parallelization setup:
398- doParallel :: stopImplicitCluster()
399- foreach :: registerDoSEQ()
402+ if (use_parallel ) {
403+ doParallel :: stopImplicitCluster()
404+ foreach :: registerDoSEQ()
405+ }
400406```
401407
402408#### Predictive performance plot from final ` cv_varsel() ` run
@@ -544,8 +550,8 @@ print(smmry, digits = 1)
544550 5 X6 0.0 -0.208 -0.27 -0.151
545551 6 X3 0.0 -0.214 -0.26 -0.169
546552 7 X8 0.5 -0.003 -0.02 0.016
547- 8 X11 0.0 -0.010 -0.03 0.009
548- 9 X7 0.0 0.003 -0.01 0.021
553+ 8 X11 0.0 -0.010 -0.03 0.008
554+ 9 X7 0.0 0.003 -0.01 0.020
549555
550556 Reference model performance evaluation summary with `deltas = TRUE`:
551557 mlpd mlpd.lower mlpd.upper
@@ -570,7 +576,7 @@ str(perf)
570576 $ submodels :'data.frame': 10 obs. of 4 variables:
571577 ..$ size : num [1:10] 0 1 2 3 4 5 6 7 8 9
572578 ..$ mlpd : num [1:10] -0.976 -0.786 -0.555 -0.553 -0.519 ...
573- ..$ mlpd.lower: num [1:10] -1.049 -0.867 -0.623 -0.637 -0.609 ...
579+ ..$ mlpd.lower: num [1:10] -1.049 -0.868 -0.623 -0.637 -0.609 ...
574580 ..$ mlpd.upper: num [1:10] -0.903 -0.704 -0.487 -0.469 -0.429 ...
575581 $ reference_model: Named num [1:3] 0 0 0
576582 ..- attr(*, "names")= chr [1:3] "mlpd" "mlpd.lower" "mlpd.upper"
0 commit comments