bioLeak: Leakage-Aware Modeling and Diagnostics for Machine Learning in R
Organizations: Department of Biostatistics and Medical Informatics, Faculty of Medicine, Trakya University, 22030 Edirne, Türkiye
Abstract
Data leakage remains a recurrent source of optimistic bias in biomedical machine learning studies. Standard row-wise cross-validation and globally estimated preprocessing steps are often inappropriate for data with repeated measurements, study-level heterogeneity, batch effects, or temporal dependencies. This paper describes bioLeak, an R package for constructing leakage-aware resampling workflows and for auditing fitted models for common leakage mechanisms. The package provides leakage-aware split construction, train-fold-only preprocessing, cross-validated model fitting, nested hyperparameter tuning, post hoc leakage audits, and HTML reporting. The implementation supports binary classification, multiclass classification, regression, and survival analysis, with task-specific metrics and S4 containers for splits, fits, audits, and inflation summaries. The simulation artifacts show how apparent performance changes under controlled leakage mechanisms, and the case study illustrates how guarded and leaky pipelines can yield materially different conclusions on multi-study transcriptomic data. The emphasis throughout is on software design, reproducible workflows, and interpretation of diagnostic output.
Figures & tables
| Stage | Function | Main output or role |
|---|---|---|
| Split construction | make_split_plan() | Leakage-aware split plans for subject, batch, study, or time-ordered resampling. |
| Cross-validated fitting | fit_resample() | Fold predictions, fold metrics, aggregated performance summaries, preprocessing state, and refit metadata. |
| Nested tuning | tune_resample() | Nested cross-validation for hyperparameter tuning with leakage-aware outer and inner folds. |
| Leakage auditing | audit_leakage() | Permutation-gap summaries, batch or study association tests, target scans, duplicate detection, and mechanism summaries. |
| Audit reporting | audit_report() | Self-contained HTML summaries suitable for documentation and sharing. |
| comparison | delta_lsi() | Repeat-level comparison of leaky and guarded pipelines, including robust inflation estimates and randomization-based inference. |
| Mechanism | ||||
|---|---|---|---|---|
| None (clean baseline) | 0.57 (.03) | 0.82 (.02) | 0.98 (.01) | 1.00 |
| Subject overlap | 0.93 (.01) | 1.00 | 1.00 | 1.00 |
| Batch confounding | 0.95 (.01) | 1.00 | 1.00 | 1.00 |
| Peek normalization | 1.00 | 1.00 | 1.00 | 1.00 |
| Look-ahead | 0.65 (.03) | 0.95 (.01) | 1.00 | 1.00 |
| Mechanism | ||||
|---|---|---|---|---|
| None (clean baseline) | 0.08 (.02) | 0.09 (.02) | 0.08 (.02) | 0.06 (.02) |
| Subject overlap | 0.85 (.03) | 1.00 | 1.00 | 1.00 |
| Batch confounding | 0.89 (.03) | 1.00 | 1.00 | 1.00 |
| Peek normalization | 1.00 | 1.00 | 1.00 | 1.00 |
| Look-ahead | 0.09 (.02) | 0.09 (.02) | 0.09 (.02) | 0.06 (.02) |
| Mode | None | Subj. overlap | Batch conf. | Peek norm. | Look-ahead |
|---|---|---|---|---|---|
| Subj. grouped | 0.06 (.03) | 1.00 | 0.98 (.02) | 1.00 | 0.04 (.03) |
| Batch blocked | 0.04 (.03) | 1.00 | 0.02 (.02) | 1.00 | 0.02 (.02) |
| Study LOOCV | 0.06 (.03) | 1.00 | 0.98 (.02) | 1.00 | 0.04 (.03) |
| Time series | 0.02 (.02) | 1.00 | 0.98 (.02) | 1.00 | 0.02 (.02) |
| Guarded | Guarded (no FS) | Naive (no leaks) | Leaky | |
| Split design | Study LOOCV | Study LOOCV | 5-fold CV | 5-fold CV |
| Feature selection | t-test top 100 | None | None | None |
| Leak features | No | No | No | Yes |
| AUC | 0.610 | 0.682 | 0.717 | 0.810 |
| SD | 0.063 | 0.079 | 0.025 | 0.024 |
| Perm. gap | 0.101 | 0.173 | 0.208 | 0.301 |
| Function | Binary | Multiclass | Regression | Survival |
|---|---|---|---|---|
| make_split_plan | ✓ | ✓ | ✓ | ✓ |
| fit_resample | ✓ | ✓ | ✓ | ✓ |
| tune_resample | ✓ | ✓ | ✓ | — |
| audit_leakage | ✓ | (✓) | (✓) | (✓) |
| delta_lsi | ✓ | (✓) | (✓) | (✓) |
| Target scan | ✓ | (✓) | (✓) | — |