Skip to content

Commit

Permalink
use future for parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Mar 7, 2025
1 parent b9dea2a commit 096da9c
Show file tree
Hide file tree
Showing 21 changed files with 3,058 additions and 575 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions _freeze/learn/work/bayes-opt/index/execute-results/html.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions _freeze/learn/work/tune-svm/index/execute-results/html.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions _freeze/start/tuning/index/execute-results/html.json

Large diffs are not rendered by default.

255 changes: 0 additions & 255 deletions learn/models/bootstrap-metrics/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ mars_res <-
grid = grid,
control = ctrl
)
#> Warning: ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
```
:::

Expand Down Expand Up @@ -207,251 +202,6 @@ There's a tidymodels function called `int_pctl()` for this purpose. It has a met
```{.r .cell-code}
set.seed(140)
mars_boot <- int_pctl(mars_res, alpha = 0.10)
#> Warning: ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
#> ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
mars_boot
#> # A tibble: 98 × 7
#> .metric .estimator .lower .estimate .upper .config num_terms
Expand Down Expand Up @@ -560,11 +310,6 @@ mars_boot %>% filter(num_terms == 40)
```{.r .cell-code}
set.seed(168)
mars_test_boot <- int_pctl(mars_test_res, alpha = 0.10)
#> Warning: ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
mars_test_boot
#> # A tibble: 2 × 6
#> .metric .estimator .lower .estimate .upper .config
Expand Down
4 changes: 2 additions & 2 deletions learn/models/bootstrap-metrics/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ This article discusses using [the bootstrap](https://en.wikipedia.org/wiki/Boots
library(tidymodels)
# quietly use parallel process
library(doMC)
library(future)
tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)
registerDoMC(cores = parallel::detectCores(logical = FALSE))
plan(multisession, workers = parallel::detectCores(logical = FALSE))
```

We'll use the [delivery time data](https://modeldata.tidymodels.org/reference/deliveries.html) and follow the analysis used in [_Applied Machine Learning for Tabular Data_](https://aml4td.org/chapters/whole-game.html#sec-delivery-times). The outcome is the time for food to be delivered, and the predictors include the day/hour of the order, the distance, and what was included in the order (columns starting with `item_`):
Expand Down
2 changes: 1 addition & 1 deletion learn/models/calibration/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ For regression models, there is `cal_plot_regression()` and `cal_*_linear()`. Th
#> dplyr * 1.1.4 2023-11-17 [1] CRAN (R 4.4.0)
#> ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.0)
#> infer * 1.0.7 2024-03-25 [1] CRAN (R 4.4.0)
#> klaR * 1.7-3 2023-12-13 [1] CRAN (R 4.4.0)
#> klaR 1.7-3 2023-12-13 [1] CRAN (R 4.4.0)
#> parsnip * 1.3.0 2025-02-14 [1] CRAN (R 4.4.2)
#> probably * 1.0.3 2024-02-23 [1] CRAN (R 4.4.0)
#> purrr * 1.0.4 2025-02-05 [1] CRAN (R 4.4.1)
Expand Down
4 changes: 2 additions & 2 deletions learn/models/calibration/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ source(here::here("common.R"))
library(tidymodels)
library(probably)
library(discrim)
library(doMC)
library(future)
registerDoMC(cores = parallel::detectCores())
plan(multisession, workers = parallel::detectCores())
pkgs <- c("tidymodels", "probably", "discrim", "klaR")
```
Expand Down
16 changes: 1 addition & 15 deletions learn/models/conformal-regression/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ folds <- vfold_cv(train_data)
nnet_rs <-
nnet_wflow %>%
fit_resamples(folds, control = ctrl)
#> Warning: ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.

collect_metrics(nnet_rs)
#> # A tibble: 2 × 6
Expand Down Expand Up @@ -451,15 +446,6 @@ We can recreate the CV+ interval for this new version of the data:


::: {.cell layout-align="center"}

```
#> Warning: ! tune detected a parallel backend registered with foreach but no
#> backend registered with future.
#> ℹ Support for parallel processing with foreach was soft-deprecated in
#> tune 1.2.1.
#> ℹ See ?parallelism (`?tune::parallelism()`) to learn more.
```

::: {.cell-output-display}
![](figs/cv-redux-1.svg){fig-align='center' width=70%}
:::
Expand Down Expand Up @@ -644,7 +630,7 @@ If you are interested and would like to learn more, try these resources:
#> dplyr * 1.1.4 2023-11-17 [1] CRAN (R 4.4.0)
#> ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.0)
#> infer * 1.0.7 2024-03-25 [1] CRAN (R 4.4.0)
#> nnet * 7.3-20 2025-01-01 [1] CRAN (R 4.4.1)
#> nnet 7.3-20 2025-01-01 [1] CRAN (R 4.4.1)
#> parsnip * 1.3.0 2025-02-14 [1] CRAN (R 4.4.2)
#> probably * 1.0.3 2024-02-23 [1] CRAN (R 4.4.0)
#> purrr * 1.0.4 2025-02-05 [1] CRAN (R 4.4.1)
Expand Down
4 changes: 2 additions & 2 deletions learn/models/conformal-regression/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ source(here::here("common.R"))
#| cache: false
library(tidymodels)
library(probably)
library(doMC)
library(future)
# -------------------------------------------------------------------------
tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)
registerDoMC(cores = parallel::detectCores())
plan(multisession, workers = parallel::detectCores())
# ------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions learn/statistics/survival-metrics/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ As an example, we'll use the building complaints data from the [case study](../s
library(tidymodels)
library(censored)
#> Loading required package: survival
#>
#> Attaching package: 'survival'
#> The following object is masked from 'package:future':
#>
#> cluster

building_complaints <- modeldatatoo::data_building_complaints()

Expand Down
6 changes: 3 additions & 3 deletions learn/statistics/survival-metrics/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ source(here::here("common.R"))
library(tidymodels)
library(probably)
library(patchwork)
library(doParallel)
library(future)
library(sessioninfo)
cl <- makePSOCKcluster(parallel::detectCores(logical = FALSE))
registerDoParallel(cl)
plan(multisession, workers = parallel::detectCores())
pkgs <- c("tidymodels", "censored", "modeldatatoo")
theme_set(theme_bw() + theme(legend.position = "top"))
Expand Down
Loading

0 comments on commit 096da9c

Please sign in to comment.