Displaying 1 result from an estimated 1 matches for "train_pos".
Did you mean:
main_pos
2016 Apr 04
0
Does this code execute the bagging correctly ?!
...t,newdata=testing)
error<-sqrt((sum((testing$y-predictions)^2))/nrow(testing))
library(foreach)
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))
Does it execute bagging correctly ?
if yes , How to rank in...