How to apply an ensemble of random forests in R

ensemble_methods
boosting

#1

Hello,

I am trying to implement ensembles of Random Forests.I am using R and wan’t to know how do I achieve this.Like in python we can do something like:

clf = ensemble.RandomForestClassifier(n_estimators=200,n_jobs=-1,random_state=0)
  clf.fit(X_train, y)

Is there any such way in R to do the same?I have seen the adaboost and mboost packages but could not find any such implementation.


#2

Hi,

You could use the ‘randomForest’ package in R to do the same.

library(randomForest)
fit <- randomForest(as.factor(DV) ~. , data=train, importance=TRUE, ntree=200)
Prediction <- predict(fit, test)

Hope this helps!