Hello,
In ensemble methods how do I combine the predictions from multiple models(one based on linear regression,one on random forests).
My code:
length_divisor<-6
iterations<-5000
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)
}
lm_predictions<-rowMeans(predictions)
library(randomForest)
rf_fit<-randomForest(y~x1+x2+x3,data=training,ntree=500)
rf_predictions<-predict(rf_fit,newdata=testing)
Now if I want to predict based on these two models how do I do it?
For example I want to now apply the predictions from linear regression and random forests for a better model and find out the error rate.Then I want to compare this error rate with linear reg model and random forest model.
Can somebody please help me with this!!