mlh_outsample_row_indices {kdry} | R Documentation |
mlh_outsample_row_indices
Description
Machine learning helper function to convert a vector of (in- sample) row indices of a fold into out-of-sample row indices.
Usage
mlh_outsample_row_indices(fold_list, dataset_nrows, type = NULL)
Arguments
fold_list |
A list of integer vectors that describe the row indices of cross-validation folds. The list must be named. |
dataset_nrows |
An integer. The number of rows in the dataset dataset. This parameter is required in order to compute the out-of-sample row indices. |
type |
A character. To be used if the out-of-sample row indices need to
be formatted in a special manner (default: |
Value
If type = NULL
, returns a list of same length as fold_list
with
each item containing a vector of out-of-sample row indices. If
type = "glmnet"
, a data.table is returned with two columns and each row
representing one observation of the dataset that is assigned to a specific
test fold. The column "fold_id" should be passed further on to the argument
foldid
of glmnet::cv.glmnet
.
Examples
fold_list <- list(
"Fold1" = setdiff(seq_len(100), 1:33),
"Fold2" = setdiff(seq_len(100),66:100),
"Fold3" = setdiff(seq_len(100),34:65)
)
mlh_outsample_row_indices(fold_list, 100)
mlh_outsample_row_indices(fold_list, 100, "glmnet")