dot-permute_labels_factory: Restricted permutation label factory

.permute_labels_factoryR Documentation

Restricted permutation label factory

Description

Builds a closure that generates permuted outcome vectors per fold while respecting grouping/batch/study/time constraints used in audit_leakage(). Numeric outcomes can be stratified by quantiles to preserve outcome structure under permutation.

Usage

.permute_labels_factory(
  cd,
  outcome,
  mode,
  folds,
  perm_stratify,
  time_block,
  block_len,
  seed,
  group_col = NULL,
  batch_col = NULL,
  study_col = NULL,
  time_col = NULL,
  verbose = FALSE
)

Arguments

cd

data.frame of sample metadata.

outcome

outcome column name.

mode

resampling mode (subject_grouped, batch_blocked, study_loocv, time_series).

folds

list of fold descriptors from LeakSplits. When compact splits are used, fold assignments are read from the fold_assignments attribute.

perm_stratify

logical or "auto"; if TRUE, permute within strata.

time_block

time-series block permutation method.

block_len

block length for time-series permutations.

seed

integer seed.

group_col, batch_col, study_col

optional metadata columns.

time_col

optional metadata column name for time-series ordering.

verbose

logical; print progress messages.

Value

A function that returns a list of permuted outcome vectors, one per fold.


bioLeak documentation built on March 6, 2026, 1:06 a.m.