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
I'm having trouble with tuning k-means clustering in parallel. Everything works as expected when running sequentially, but in parallel the following warning is returned:
Warning: All models failed. See the `.notes` column.
No error is thrown so the code continues running, but the returned data frame is empty.
Reproducible example
library(doParallel)
#> Loading required package: foreach#> Loading required package: iterators#> Loading required package: parallel
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.3.3#> Warning: package 'ggplot2' was built under R version 4.3.3#> Warning: package 'tidyr' was built under R version 4.3.3#> Warning: package 'readr' was built under R version 4.3.3#> Warning: package 'dplyr' was built under R version 4.3.3#> Warning: package 'stringr' was built under R version 4.3.3#> Warning: package 'lubridate' was built under R version 4.3.3
library(tidymodels)
#> Warning: package 'dials' was built under R version 4.3.3#> Warning: package 'scales' was built under R version 4.3.3#> Warning: package 'parsnip' was built under R version 4.3.3#> Warning: package 'recipes' was built under R version 4.3.3#> Warning: package 'workflows' was built under R version 4.3.3
library(tidyclust)
#> Warning: package 'tidyclust' was built under R version 4.3.3#> #> Attaching package: 'tidyclust'#> The following objects are masked from 'package:parsnip':#> #> knit_engine_docs, list_md_problems
library(tune)
my_parallel<-parallel::makePSOCKcluster(parallel::detectCores(logical=FALSE))
doParallel::registerDoParallel(my_parallel)
set.seed(123)
penguin_data<-modeldata::penguins %>% drop_na()
data_form<-~bill_length_mm+bill_depth_mmpenguin_recipe<- recipe(data_form, data=penguin_data) %>%
step_normalize(all_predictors())
kmeans_spec<- k_means(num_clusters= tune(),
engine='stats',
mode='partition')
kmeans_wkfl<- workflow() %>%
add_recipe(penguin_recipe) %>%
add_model(kmeans_spec)
cl_resamples<- vfold_cv(penguin_data, v=2)
cl_grid<- tibble(num_clusters=1:10)
tuning_result<- tune_cluster(kmeans_wkfl,
resamples=cl_resamples,
grid=cl_grid,
metrics= cluster_metric_set(sse_within_total))
#> Warning: All models failed. See the `.notes` column.
The problem
I'm having trouble with tuning k-means clustering in parallel. Everything works as expected when running sequentially, but in parallel the following warning is returned:
No error is thrown so the code continues running, but the returned data frame is empty.
Reproducible example
Created on 2024-04-26 with reprex v2.1.0
Session info
The text was updated successfully, but these errors were encountered: