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?

$\endgroup$
1

1 Answer 1

3
$\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

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.