modelSampling | R Documentation |
This function creates a sampling matrix for cross-validation, specifying which samples should be used for training and validation across multiple iterations. It supports two sampling types: "window" (systematic shifting) and "random" (random selection).
modelSampling(
vect,
sampling.type = c("window", "random"),
training.pc = 90,
iteration = 10
)
vect |
A matrix or data frame with samples as columns, used to determine the sampling order and dimensions. |
sampling.type |
A character string indicating the sampling method, either '"window"' or '"random"'. Default is 'c("window", "random")'. - '"window"': Sequentially shifts the training window across samples. - '"random"': Randomly selects training samples in each iteration. |
training.pc |
An integer representing the percentage of samples to be allocated for training in each iteration. Default is 90. |
iteration |
An integer specifying the number of sampling iterations. Default is 10. |
The function creates a binary sampling matrix with rows as sample names and columns as iterations. Cells with '1' indicate the sample is in the training set, while '0' indicates the sample is in the validation set. For '"window"' sampling, a moving window of training samples shifts across each iteration. For '"random"' sampling, training samples are selected randomly in each iteration.
**Sampling Process**: - For '"window"': A sequential window of 'size.train' is assigned for training, wrapping around if needed. - For '"random"': A random subset of size 'size.train' is selected as the training set in each iteration.
A binary matrix with dimensions '(number of samples) x (iteration)', indicating training ('1') and validation ('0') samples for each iteration.
## Not run:
vect <- matrix(rnorm(100), nrow = 10) # Example data
sampling_matrix <- modelSampling(vect, sampling.type = "random", training.pc = 80, iteration = 5)
print(sampling_matrix)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.