4
$\begingroup$

What learning algorithms are "embarrassingly parallel?" I'll kick it off with the obvious example from the foreach documentation:

rf <- foreach(ntree = rep(250, 4), .combine = combine, .packages = "randomForest") %dopar%
 randomForest(x, y, ntree = ntree)

What else is out there that can be easily parallelized with foreach?

| cite | improve this question | | | | |
$\endgroup$
2
$\begingroup$

Bagging is embarrassingly parallel:

bagging<-function(training,testing,length_divisor=4,iterations=1000)
{
predictions<-foreach(m=1:iterations,.combine=cbind) %do% {
training_positions <- sample(nrow(training), size=floor((nrow(training)/length_divisor)))
train_pos<-1:nrow(training) %in% training_positions
lm_fit<-lm(y~x1+x2+x3,data=training[train_pos,])
predict(lm_fit,newdata=testing)
}
rowMeans(predictions)
}

Code from R, Ruby, and Finance

| cite | improve this answer | | | | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.