Talk:Model Evaluation: Cross-validation for regression task/@comment-25807400-20141203200333

Here is another way to create folds for cross validation:

> library(caret) ## package for Classification And REgression Training

> folds <- createFolds(iris$Species, k = 4, list = TRUE)

> folds$Fold1 ## or folds$Fold2, folds$Fold3, that depends on your k.

The result should be something like this:

> folds$Fold1

[1]   7  13  15  16  18  20  24  28  31  34  42  47  54  55  57  64  71  73  78  81  83  84  90  92

[25] 107 113 114 120 123 129 135 136 138 141 149 150

After the splits, we can acessing the subset use this code:

> iris[folds$Fold1,]