cv_one_env_out: Leave one environment out cross validation folds generation

View source: R/utils.R

cv_one_env_outR Documentation

Leave one environment out cross validation folds generation

Description

Generates folds for the leave one environment out cross validation. In each fold on environment is taken to be the testing set and all the remaining ones to be the training set. It is a special case of the cv_one_group_out where the groups are the environments.

Usage

cv_one_env_out(envs, envs_proportion = 1, folds_per_env = 5)

Arguments

envs

(vector) The vector of all environments.

envs_proportion

(numeric(1)) The proportion of data within each environment to be taken randomly to be the testing set in each fold. If 1, then all the whole environment is taken to be the testing set. 1 by default.

folds_per_env

(numeric(1)) The number of folds to generate for each environment when envs_proportion is less than 1. 5 by default.

Value

A list with length(unique(envs)) * folds_per_env elements where each element is a named list with the elements training wich includes the indices of those records to be part of the training set and testing wich includes the indices of those records to be part of the testing set. Training and testing sets of each fold are exhaustive and mutually exclusive.

Examples

## Not run: 
# Generates random data
envs <- rep(paste0("env", 1:4), 10)
folds <- cv_one_env_out(envs)
# Indices of training set in fold 1
folds[[1]]$training
# Indices of testing set in fold 1
folds[[1]]$testing

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.