Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caret train function - unable to find variable "optimismBoot"

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

like image 698
cag Avatar asked Sep 15 '17 17:09

cag


2 Answers

There is a reference to this issue on Caret github page. They seem to have fixed it lately

See here : https://github.com/topepo/caret/issues/706

In that case, I guess installing caret directly from github should solve the problem .

devtools::install_github('topepo/caret/pkg/caret')

See here : https://github.com/topepo/caret

Follow these steps: (I'm assuming you are using RStudio)

  1. Install devtools package as usual
  2. Run the command devtools::install_github('topepo/caret/pkg/caret') and check the output to make sure the package is refreshed from github
  3. Restart RStudio/R. The version of caret in package explorer will be same as before, but the package would be using new code
  4. To make dead sure it is updated, you can output the source code of this changed internal function with caret:::nominalTrainWorkflow and make sure the following line is in there : export <- c("optimism_xy"). If you do it right now, the line would have optimismBoot instead of optimism_xy

PS: Latest version of Caret is dated September 7, 2017. So updating should solve the issue as well.

like image 68
R.S. Avatar answered Nov 01 '22 17:11

R.S.


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

like image 43
M. Adam Avatar answered Nov 01 '22 18:11

M. Adam