fcv {functionals} | R Documentation |
Functional Cross-Validation mapping
Description
Applies a user-defined function '.f' to each element of '.splits', typically from cross-validation objects such as 'rsample::vfold_cv()'.
Usage
fcv(.splits, .f, ncores = NULL, pb = FALSE, ...)
Arguments
.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'. |
Value
A list of results returned by applying '.f' to each element of '.splits'.
Examples
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)
}
[Package functionals version 0.5.0 Index]