I think I understand the concept of cross validation. I built a model using kfolds and assessed it's performance based on the mean absolute error of n observations after having iterated test/train on ten folds.
Within each iteration I train a model then test it. So there are in fact k models.
Which one do I use for prediction?
# cross validation
for ( f in folds ) {
train <- ptrain[-f,]
test <- ptrain[f,]
model <- lm(paste("loss ~ ",paste(predictors, collapse="+"),sep=""), data=train)
predictions <- predict(model, interval="prediction", newdata=test)
temp <- as.data.frame(predictions)
cv_prediction <- rbind(cv_prediction, temp)
testsetCopy <- rbind(testsetCopy, test)
}
After running this kfold loop, the model is just the last iteration of train. If I wanted to apply my model, what is my model? Trained on all available data?