Skip to content
Quantoros

Is it easy to parallelize training of a random forest model? How can we do it?

Classic MLLevel: IntermediateRandom forest

Is it easy to parallelize training of a random forest model? How can we do it?

Hints
  • How are training samples formed and how do ensemble trees differ?
  • Consider correlation between model errors, not only individual quality.

Answer

Yes, R provides a simple way to parallelize training of random forests on large scale data. It makes use of a parameter called multicombine which can be set to TRUE for parallelizing random forest computations.

rf <- foreach(ntree=rep(25000, 6), .combine=randomForest::combine,
              .multicombine=TRUE, .packages='randomForest') %dopar% {
    randomForest(x, y, ntree=ntree)
}

Source and licence: Alexey Grigorev & contributors — Data Science Interviews · CC-BY-4.0

Related questions