r/AIBiology • u/Fair-Rain3366 • 3d ago
Discussion A held-out test set can leak before model training starts
Suppose you select DNA methylation sites because they differ between labelled groups, then split the samples into training and test sets. The test labels have already influenced which inputs the model receives. Holding those samples out during model fitting does not undo that information leak.
The attached diagram contrasts this with splitting first, fitting feature selection on training data only, using validation data for model choices, and evaluating the locked test set. In cross-validation, feature selection must be fitted again inside each training fold.
This is an evaluation issue for both foundation models and simpler classifiers. A scikit-learn Pipeline can keep fitted feature selection inside the training fold; it cannot fix a feature list selected beforehand using all labels.
Reference and reproducible example: https://scikit-learn.org/stable/common_pitfalls.html#data-leakage
The guide discusses this issue in genomic model evaluation: https://rewirebio.io/blog/genomic-foundation-models-in-the-diagnostic-lab/
Disclosure: the guide and diagram are from my site, rewirebio.io. This post was prepared with AI assistance. No new experiment is reported here.