split_cv | R Documentation |
A robust cross-validation splitting utility for multiple datasets with advanced stratification and configuration options.
split_cv(
split_dt,
v = 10,
repeats = 1,
strata = NULL,
breaks = 4,
pool = 0.1,
...
)
split_dt |
|
v |
The number of partitions of the data set. |
repeats |
The number of times to repeat the V-fold partitioning. |
strata |
A variable in |
breaks |
A single number giving the number of bins desired to stratify a numeric stratification variable. |
pool |
A proportion of data used to determine if a particular group is too small and should be pooled into another group. We do not recommend decreasing this argument below its default of 0.1 because of the dangers of stratifying groups that are too small. |
... |
These dots are for future extensions and must be empty. |
Advanced Cross-Validation Mechanism:
Input dataset validation
Stratified or unstratified sampling
Flexible fold generation
Train-validate set creation
Sampling Strategies:
Supports multiple dataset processing
Handles stratified and unstratified sampling
Generates reproducible cross-validation splits
list
of data.table
objects containing:
splits
: Cross-validation split objects
train
: Training dataset subsets
validate
: Validation dataset subsets
Important Constraints:
Requires non-empty input datasets
All datasets must be data.frame
or data.table
Strata column must exist if specified
Computational resources impact large dataset processing
rsample::vfold_cv()
Core cross-validation function
# Prepare example data: Convert first 3 columns of iris dataset to long format and split
dt_split <- w2l_split(data = iris, cols2l = 1:3)
# dt_split is now a list containing 3 data tables for Sepal.Length, Sepal.Width, and Petal.Length
# Example 1: Single cross-validation (no repeats)
split_cv(
split_dt = dt_split, # Input list of split data
v = 3, # Set 3-fold cross-validation
repeats = 1 # Perform cross-validation once (no repeats)
)
# Returns a list where each element contains:
# - splits: rsample split objects
# - id: fold numbers (Fold1, Fold2, Fold3)
# - train: training set data
# - validate: validation set data
# Example 2: Repeated cross-validation
split_cv(
split_dt = dt_split, # Input list of split data
v = 3, # Set 3-fold cross-validation
repeats = 2 # Perform cross-validation twice
)
# Returns a list where each element contains:
# - splits: rsample split objects
# - id: repeat numbers (Repeat1, Repeat2)
# - id2: fold numbers (Fold1, Fold2, Fold3)
# - train: training set data
# - validate: validation set data
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.