Caret train function - unable to find variable "optimismBoot"

Viewed 4859

I'm new to R and RStudio and have been experimenting with predictive modeling. The following train function works without parallel processing but when I implement doSNOW makeCluster, I get the error shown below related to a variable named "optimismBoot". I've searched in vain for a resolution, tried installing and uninstalling packages, but nothing works. Any insight appreciated.

 cl <- makeCluster(2, type = "SOCK")

 registerDoSNOW(cl)

 caret.cv <- train(ReturnedToMF ~ .,
                       data = trees.cetstrain,
                       method = "xgbTree",
                       tuneGrid = tune.grid,
                       trControl = cetstrain.control)
Error in e$fun(obj, substitute(ex), parent.frame(), e$data) : 
  unable to find variable "optimismBoot"

I found the following link on this site but it doesn't really provide a solution to make parallel processing work: Caret on R spills "unable to find variable "optimismBoot"" error message

3 Answers

I was facing this problem when I updated the packages the new caret version is caret_6.0-77, now I solve it by download the old version of caret package is caret_6.0-76 from the cran archives packages see this link Click here!, and then install the package file locally using Rstudio from the Tools menu and then select install packages it appear dialog box from the pop-menu choose to install from file (.extension)

I hope this helpful

I'd say use the example from the docs for parallel processing.

library(parallel)
library(doMC)
# use all cores except one
doMC::registerDoMC(cores = parallel::detectCores() - 1)

That's all you have to do, then you can run train() and it should be using the number of cores you specified. I adapted it a bit to dynamically detect number of cores with the parallel library.

Related