r - Why is using %do% loop is using multiple processors? Expected sequential loop -


i'm using foreach , reading on e.g.

my understanding use %dopar% parallel processing , %do% sequential.

as happens having issues %dopar% , while trying debug changed thought sequential loop using %do%. happened have terminal open , noticed processors running while ran loop.

is expected?

reproducible example:

library(tidyverse) library(caret) library(foreach)  # expected see parallel here because caret , xgb train() xgbfit <- train(species ~ ., data = iris, method = "xgbtree",                  trcontrol = traincontrol(method = "cv", classprobs = true))  iris_big <- do.call(rbind, replicate(1000, iris, simplify = f))  nr <- nrow(iris_big) n <- 1000 # loop on in chunks of 20 pieces <- split(iris_big, rep(1:ceiling(nr/n), each=n, length.out=nr)) lenp <- length(pieces)  # did not expect see parallel processing take place when running block below predictions <- foreach(i = seq_len(lenp)) %do% {    # prediction   preds <- pieces[[i]] %>%      mutate(xgb_prediction = predict(xgbfit, newdata = .))    return(preds) }  bah <- do.call(rbind, predictions) 

enter image description here

my best guess these processes still running previous runs.

it same when using foreach::registerdoseq()?

my second guess predict runs in parallel.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -