title: Speed up cross validated random forest approach by parallel computing
body: <p>I'm trying to speed up my random forest approach by parallel computing. My dataset contains of 20.000 rows and 10 columns. Dependent variable, which could be predicted, is a numerical and there are two factors between independent variables (one has 2 levels and second one has 504 levels). </p>
  
  <p>I think the function train does coding all the factor variables into dummy variables, so decoding is not needed in this case.</p>
  
  <p>Please, could you give me some useful advice, how to speed up the following code, I would appreciate any of advice. The solution below is never ending. Thanks a lot in advance.</p>
  
  <pre><code>library(doParallel); library(caret)
  
  set.seed(975)
  forTraining &lt;- createDataPartition(DATA$NumVar,
                                 p = 3/4)[[1]]
  trainingSet &lt;- DATA[forTraining,]
  testSet &lt;- DATA[-forTraining,]
  
  controlObject &lt;- trainControl(method = "repeatedcv",
                            repeats = 5,
                            number = 10)
  #run model in parallel
  cl &lt;- makeCluster(detectCores())
  registerDoParallel(cl)
  
  set.seed(669)
  rfModel &lt;- train(NumVar ~ .,
               data = trainingSet,
               method = "rf",
               tuneLength = 10,
               ntrees = 1000,
               importance = TRUE,
               trControl = controlObject)
  stopCluster(cl)
  </code></pre>