Splits a single tabular data object into distinctly-labelled
training, test, and (optionally) validation partitions, with optional
stratification on a column.
Usage
morie_ml_split(
data,
prop = c(train = 0.6, test = 0.2, validation = 0.2),
strata = NULL,
seed = 42L
)
Arguments
- data
A data.frame.
- prop
Named numeric of partition proportions; names are matched
case-insensitively and by partial match to "train"/"test"/
"validation" (ML1.1b). Must sum to 1.
- strata
Optional column name to stratify the split on.
- seed
RNG seed for reproducibility.
Value
An object of class morie_ml_split: a list with train,
test, and (if requested) validation data.frames plus a roles
vector giving each row's assignment.
Examples
sp <- morie_ml_split(mtcars, c(train = 0.6, test = 0.4), seed = 1)
nrow(sp$train) + nrow(sp$test)
#> [1] 32