cv_leve_one_group_out | R Documentation |
Generates folds for the leave one group out cross validation. In each fold on group is taken to be the testing set and all the remaining ones to be the training set.
cv_leve_one_group_out(data)
data |
( |
A list
with length(unique(data))
elements where each element is a named
list
with the elements training
wich includes the indices of those
records to be part of the training set and testing
wich includes the
indices of those records to be part of the testing set. Training and testing
sets of each fold are exhaustive and mutually exclusive.
## Not run:
# Generates random data
data <- c(rep("A", 10), rep("B", 20), rep("C", 30))
folds <- cv_leve_one_group_out(data)
# Indices of training set in fold 1
folds[[1]]$training
# Indices of testing set in fold 1
folds[[1]]$testing
# Verify fold 1 only contains elements of group A
table(data[folds[[1]]$training])
table(data[folds[[1]]$testing])
# Verify fold 2 only contains elements of group B
table(data[folds[[2]]$training])
table(data[folds[[2]]$testing])
# Verify fold 3 only contains elements of group C
table(data[folds[[3]]$training])
table(data[folds[[3]]$testing])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.