fcv | R Documentation |
Applies a user-defined function '.f' to each element of '.splits', typically from cross-validation objects such as 'rsample::vfold_cv()'.
fcv(.splits, .f, ncores = NULL, pb = FALSE, ...)
.splits |
A list of resample splits (e.g., from 'rsample::vfold_cv()'). |
.f |
A function to apply to each split. Typically expects a single 'split' object. |
ncores |
Integer. Number of cores to use for parallel processing. Default is 'NULL' (sequential). |
pb |
Logical. Whether to display a progress bar. Default is 'FALSE'. |
... |
Additional arguments passed to '.f'. |
A list of results returned by applying '.f' to each element of '.splits'.
if (requireNamespace("rsample", quietly = TRUE)) {
set.seed(123)
cv_splits <- rsample::vfold_cv(mtcars, v = 5)
# Apply summary over training sets
fcv(cv_splits$splits, function(split) {
summary(rsample::analysis(split))
})
# With progress and parallel execution
fcv(cv_splits$splits, function(split) {
summary(rsample::analysis(split))
}, ncores = 2, pb = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.