| as_rsample | R Documentation |
Convert LeakSplits to an rsample resample set
as_rsample(x, data = NULL, ...)
x |
LeakSplits object created by [make_split_plan()]. |
data |
Optional data.frame used to populate rsample splits. When NULL, the stored 'coldata' from 'x' is used (if available). |
... |
Additional arguments passed to methods (unused). |
An rsample rset object compatible with tidymodels workflows.
The returned object is a tibble with class rset containing:
splitsList-column of rsplit objects, each with
analysis (training indices) and assessment (test indices).
idCharacter column with fold identifiers (e.g., "Fold1").
id2Character column with repeat identifiers (e.g., "Repeat1") when multiple repeats are present; otherwise absent.
The object also carries attributes for group, batch,
study, time (when available from the original LeakSplits),
and bioLeak_mode indicating the original splitting mode. This allows
the splits to be used with tune::tune_grid(), rsample::fit_resamples(),
and other tidymodels functions.
if (requireNamespace("rsample", quietly = TRUE)) {
df <- data.frame(
subject = rep(1:10, each = 2),
outcome = rbinom(20, 1, 0.5),
x1 = rnorm(20),
x2 = rnorm(20)
)
splits <- make_split_plan(df, outcome = "outcome",
mode = "subject_grouped", group = "subject", v = 5)
rset <- as_rsample(splits, data = df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.