View source: R/generatefolds.R
Generate random folds for cross-validation | R Documentation |
Random folds for use in a cross validation are generated. There is the option for stratified splitting as well.
generatefolds(target, nfolds = 10, stratified = TRUE, seed = FALSE)
target |
A vector with some data, either continuous or categorical. |
nfolds |
The number of folds to produce. |
stratified |
A boolean variable specifying whether stratified random (TRUE) or simple random (FALSE) sampling is to be used when producing the folds. |
seed |
A boolean variable. If set to TRUE, the folds will always be the same. |
I was inspired by the sam command in the package TunePareto in order to do the stratified version.
A list with nfolds elements where each elements is a fold containing the indices of the data.
Michail Tsagris
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr
cv.ses
a <- generatefolds(iris[, 5], nfolds = 5, stratified = TRUE) table(iris[a[[1]], 5]) ## 10 values from each group
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.