Closed markjrieke closed 3 years ago
I don't see an error on this, running in parallel:
library(tidyverse)
library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnip
diamonds_split <- initial_split(diamonds)
diamonds_train <- training(diamonds_split)
diamonds_test <- testing(diamonds_split)
diamonds_folds <- vfold_cv(diamonds_train, v = 3)
linear_mod <-
linear_reg() %>%
set_engine("lm")
linear_rec <-
recipe(price ~ ., data = diamonds_train) %>%
bestNormalize::step_best_normalize(carat) %>%
step_dummy(all_nominal_predictors())
linear_wf <- workflow(linear_rec, linear_mod)
doParallel::registerDoParallel()
fit_resamples(linear_wf, diamonds_folds)
#> # Resampling results
#> # 3-fold cross-validation
#> # A tibble: 3 × 4
#> splits id .metrics .notes
#> <list> <chr> <list> <list>
#> 1 <split [26970/13485]> Fold1 <tibble [2 × 4]> <tibble [0 × 1]>
#> 2 <split [26970/13485]> Fold2 <tibble [2 × 4]> <tibble [0 × 1]>
#> 3 <split [26970/13485]> Fold3 <tibble [2 × 4]> <tibble [0 × 1]>
Created on 2021-11-04 by the reprex package (v2.0.1)
Can you share some more information on your setup? Can you run the reprex above and include session_info = TRUE
so we can check out what package versions you are using?
Hi Julia, thanks for checking in - here's the reprex:
library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnip
diamonds_split <- initial_split(diamonds)
diamonds_train <- training(diamonds_split)
diamonds_test <- testing(diamonds_split)
diamonds_folds <- vfold_cv(diamonds_train, v = 3)
linear_mod <-
linear_reg() %>%
set_engine("lm")
linear_rec <-
recipe(~price ~ ., data = diamonds_train) %>%
bestNormalize::step_best_normalize(carat) %>%
step_dummy(all_nominal_predictors())
linear_wf <-
workflow() %>%
add_model(linear_mod) %>%
add_recipe(linear_rec)
doParallel::registerDoParallel()
linear_rs <-
fit_resamples(
linear_wf,
diamonds_folds
)
#> Warning: All models failed. See the `.notes` column.
linear_rs
#> Warning: This tuning result has notes. Example notes on model fitting include:
#> preprocessor 1/1: Error in UseMethod("prep"): no applicable method for 'prep' applied to an object of class "c('step_best_normalize', 'step')"
#> preprocessor 1/1: Error in UseMethod("prep"): no applicable method for 'prep' applied to an object of class "c('step_best_normalize', 'step')"
#> preprocessor 1/1: Error in UseMethod("prep"): no applicable method for 'prep' applied to an object of class "c('step_best_normalize', 'step')"
#> # Resampling results
#> # 3-fold cross-validation
#> # A tibble: 3 x 4
#> splits id .metrics .notes
#> <list> <chr> <list> <list>
#> 1 <split [26970/13485]> Fold1 <NULL> <tibble [1 x 1]>
#> 2 <split [26970/13485]> Fold2 <NULL> <tibble [1 x 1]>
#> 3 <split [26970/13485]> Fold3 <NULL> <tibble [1 x 1]>
Created on 2021-11-04 by the reprex package (v2.0.1)
I haven't run a blanket package update, but I started working with a new laptop in July, so everything should be fairly up-to-date.
I see that you are on Windows, and I don't believe that doParallel::registerDoParallel()
will work on Windows like that. Have you tried something like PSOCK clusters, as shown here?
Hey Julia - I haven’t, but I’ll give it a shot when I get a chance! Do you mind elaborating on what you mean by doParallel::registerDoParallel
not being able to work on Windows like that? I’ve used ‘doParallel::registerDoParallel’ w/o issue before & the documentation does mention Windows use. Just want to make sure I can avoid any similar issues in the future! Thanks again for all your help!!
I am extremely not an expert on parallel processing on Windows, I'm afraid, so I am not the best person to answer in detail. Some things to try:
library(doParallel)
cl <- makePSOCKcluster(2) ## or how many you want
registerDoParallel(cl)
pkgs = "bestNormalize"
in a resampling control object to more specifically tell the workers that they need this packageI believe most people who use tidymodels on Windows have more success with PSOCK clusters for parallelization.
Hey Julia - no worries; definitely appreciate all the advice! I'll look into PSOCK clusters in the future for running in parallel. I'll go ahead & close since it looks like this is unrelated to recipes. Thanks again!!
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.
Hi! I ran into an issue when trying to fit resamples with a recipe using
bestNormalize::step_best_normalize()
& getting the error:Error in UseMethod("prep"): no applicable method for 'prep' applied to an object of class "c('step_best_normalize', 'step')"
. I ran into this issue fromtune
suggesting that the error was due to running in parallel. When I ran sequentially, it worked! That issue (& the recipes changelog) mention that the issue should be resolved in recipes ver 0.1.15 - I have ver 0.1.16 installed, so thought I might point out the potential existing bug!Here's a manual recreation of the error (it's pretty late as I'm writing this, so I didn't want to wait for reprex to eval):