# Are the same number of trees required to compare Random Forest against GBM?

My training set has 13,737 observations with 53 predictors. I need to compare the accuracy of Random Forest vs. GBM.

For Random Forest, I set ntree = 128 [based on Oshiro et al. (2012)] in train(data=trainset, y~., method = "rf", ntree = 128) because the default (500) was taking far too long. At 128 trees, it took 1.25 hours.

Now in train(data=trainset, y~., method = "gbm", verbose = FALSE), I have not changed the default n.tree value (100). It has been running for 2 hour now...

Should I set n.tree in gbm also to 128?
Would it be wrong to compare it against random forest otherwise?

Thank you!

• I can't think of any reason why the same number of trees should be optimal in both methods. Bagging and boosting work quite differently. – mkt - Reinstate Monica Feb 19 '19 at 16:43
• For the random forest, you could take away a lot of the pain by using a smaller value of sampsize such as sampsize=1000. At the moment, each bootstrap sample of your data is of size 8681, which is the main reason why it is taking so long. – Flounderer Feb 19 '19 at 18:42
• Isn't the default setting for sampsize (at least in randomForest package of R) equal to the size of the dataset? I.E. 13,737 not 8,681. – astel Feb 19 '19 at 18:58
• @astel I believe that's only the default if you specify replace=T but it might be the other way round. – Flounderer Feb 19 '19 at 20:27
• Right, though replace = T is also the default – astel Feb 19 '19 at 20:31