I am attempting to create a Random Forest Regression model in R using parsnip tidymodels. I am following this tutorial but using regression instead of classification. I run into an issue when I run this line of code.
doParallel::registerDoParallel()
set.seed(345)
tune_res <- tune_grid(
tune_wf,
resamples = trees_folds,
grid = 20
)
The error is as follows:
Error in checkForRemoteErrors(lapply(cl, recvResult)) :
3 nodes produced errors; first error: object '.doSnowGlobals' not found
I have looked at the following SO threada to attempt to resolve this question before asking it myself
- error: object '.doSnowGlobals' not found?
- parallel, foreach, exported object not found
- Error in check for remote errors (val): 5 nodes produced an error: object not found
None of which resolved my issue and none of which helped me fully understand what the issue may be.
For more context here is all my script:
# Splitting out the Data Between Training & Testing -------
set.seed(123)
# Creating Inital Split
tree_split <- initial_split(stc_boise, strata = DELIVERY_BUS_DAYS, prop = .80)
# Creating Training Set
tree_train <- training(tree_split)
# Creating Test Set
tree_test <- testing(tree_split)
# Create Recipe
tree_rec <- recipe(DELIVERY_BUS_DAYS ~ DOW + MVNDR_NBR + BRANCH_ID + STR_NBR + MKT_NBR + RGN_NBR + DISNACE, data = tree_train)
tree_prep <- prep(tree_rec)
juiced <- juice(tree_prep)
# Specifying the Specs of the Engine
tune_spec <- rand_forest(
mtry = tune(),
trees = 1000,
min_n = tune()
) %>%
set_mode("regression") %>%
set_engine("randomForest")
# Creating the Model Workflow
tune_wf <- workflow() %>%
add_recipe(tree_rec) %>%
add_model(tune_spec)
# Train Hyperparameters
set.seed(234)
trees_folds <- vfold_cv(tree_train)
# Tune the Model
doParallel::registerDoParallel()
set.seed(345)
tune_res <- tune_grid(
tune_wf,
resamples = trees_folds,
grid = 20
)
tune_res
I have installed all required packages for parallel computing such as: doParallel, doSNOW
, am I missing any?
If someone can provide a solution, may you share the code that I can fix it with please? And also, possibly provide an explination for the error so I fully understand why I am facing this error>