Skip to contents

Creates a proper rset object from BORG cross-validation folds, enabling direct use with tune::tune_grid(), tune::fit_resamples(), and other tidymodels infrastructure without manual conversion.

Usage

borg_rset(data = NULL, folds = NULL, cv_obj = NULL)

Arguments

data

A data frame. Required in all cases because borg_cv objects do not store the original data.

folds

A list of lists, each with train and test integer index vectors. Typically from borg_cv()$folds. Not needed when cv_obj is provided.

cv_obj

A borg_cv object. If provided, folds are extracted from it.

Value

An rset object (inheriting from tbl_df) compatible with the tidymodels ecosystem. Each row has an rsplit column containing train/test index information and an id column.

Details

The returned object works directly with tune::tune_grid(), tune::fit_resamples(), rsample::assessment(), and rsample::analysis(). The folds preserve BORG's spatial/temporal blocking structure.

Examples

# \donttest{
set.seed(42)
d <- data.frame(x = runif(100), y = runif(100), z = rnorm(100))
cv <- borg_cv(d, coords = c("x", "y"), target = "z")
rset <- borg_rset(data = d, cv_obj = cv)
class(rset)  # "borg_rset" "rset" "tbl_df" ...
# }