Hello,

I am trying to learn about ensemble models and below is one piece of code I have tried(from R-blogger) -

```
length_divisor<-4
iterations<-1000
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)
}
predictions<-rowMeans(predictions)
error<-sqrt((sum((testing$y-predictions)^2))/nrow(testing))
```

So here a random model is generated 1000 times and values are predicted.At the end the error is calculated.

This works fine for numerical continuous data and for techniques like linear reg,but how do I implement this in classification algos like RandomForests,KNN etc.My main pain point is the error calculation after the process so can somebody please help me on that