k-fold cross validation in R
Method 1:
library(e1071)
#specify the cross-validation method
tune.control <- tune.control(random = F,
nrepeat = 1,
sampling = c("cross"),
sampling.aggregate = mean,
cross = 5,
best.model = T,
performances = T)
# fit a model and use k-fold CV to evaluate performance
model <- naiveBayes(outcome ~ ., data, tune.control)