Error "no applicable method for 'predict'" when running parallel = TRUE
BigTimeStats opened this issue · 3 comments
Running the below code errors out. Is the predict function/caret package being exported into each parallel backend? Is there a way to export it as in the foreach package?
For example, you can export like this: https://stackoverflow.com/questions/45750910/how-to-export-multiple-function-or-packages-in-foreach-loop-in-r/45751174
library(doParallel)
cl <- parallel::makeCluster(10, setup_timeout = 0.5, outfile = '')
registerDoParallel(cl)
pd <- partial(rf_model, pred.var = c("x"), grid.resolution = 100, trim.outliers = TRUE,
parallel = TRUE,
train = training_balanced %>% sample_n(2000))
...
Loading required package: plyr
loaded plyr and set parent environment
Loading required package: plyr
loaded plyr and set parent environment
...
task 1 failed - "no applicable method for 'predict' applied to an object of class "c('train', 'train.formula')""
In addition: Warning messages:
1: <anonymous>: ... may be used in an incorrect context: ‘.fun(piece, ...)’
2: <anonymous>: ... may be used in an incorrect context: ‘.fun(piece, ...)’
Hi @BigTimeStats, did you try passing Alex tea functions/packages (e.g., caret) via the parops argument? You can see an example on page 429 of this article: https://journal.r-project.org/archive/2017/RJ-2017-016/RJ-2017-016.pdf. If that doesn’t work, I can fiddle with it more if you provide a reproducible example.
Thanks for the comment. Running in parallel is not usable as it took like 20x longer before I had to kill the process. Not sure what the issue is and unable to make a repro example at the moment. May investigate further soon.
Thanks @BigTimeStats, I was just running a few examples in parallel on the new foreach branch without issue, so a reproducible example would really help narrow down the issue. But it sounds like you might just have to pass paropts = list(.packages = "caret")
in your example.