View source: R/sperrorest_resampling.R
| partition_cv | R Documentation |
partition_cv creates a represampling object for
length(repetition)-repeated nfold-fold cross-validation.
partition_cv(
data,
coords = c("x", "y"),
nfold = 10,
repetition = 1,
seed1 = NULL,
return_factor = FALSE
)
data |
|
coords |
(ignored by |
nfold |
number of partitions (folds) in |
repetition |
numeric vector: cross-validation repetitions to be
generated. Note that this is not the number of repetitions, but the indices
of these repetitions. E.g., use |
seed1 |
|
return_factor |
if |
This function does not actually perform a cross-validation or partition the data set itself; it simply creates a data structure containing the indices of training and test samples.
If return_factor = FALSE (the default), a represampling object.
Specifically, this is a (named) list of length(repetition) resampling
objects. Each of these resampling objects is a list of length nfold
corresponding to the folds. Each fold is represented by a list of
containing the components train and test, specifying the indices of
training and test samples (row indices for data). If return_factor = TRUE (mainly used internally), a (named) list of length
length(repetition). Each component of this list is a vector of length
nrow(data) of type factor, specifying for each sample the fold to which
it belongs. The factor levels are factor(1:nfold).
sperrorest, represampling
data(ecuador) ## non-spatial cross-validation: resamp <- partition_cv(ecuador, nfold = 5, repetition = 5) # plot(resamp, ecuador) # first repetition, second fold, test set indices: idx <- resamp[["1"]][[2]]$test # test sample used in this particular repetition and fold: ecuador[idx, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.