| create_paired_cv_splits | R Documentation |
Create paired indices for bivariate cross-validation Ensures that paired observations (e.g., u_wind and v_wind at same location) are kept together in the same fold
create_paired_cv_splits(data, loc_col, group, k, seed = NULL)
data |
data frame containing the observations |
loc_col |
character vector of column names defining locations (e.g., c("lon", "lat") or c("x", "y")) |
group |
character, name of the group column (e.g., "direction" for wind data) |
k |
number of folds |
seed |
random seed |
list with test_idx and train_idx, each containing k lists of indices
# Example with wind data
data_long <- data.frame(
lon = rep(c(1, 2, 3, 4), 2),
lat = rep(c(1, 1, 2, 2), 2),
direction = rep(c("u_wind", "v_wind"), each = 4),
wind = rnorm(8)
)
splits <- create_paired_cv_splits(data_long, c("lon", "lat"), "direction", k = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.