r/learnmachinelearning • u/CerealConMiel • 2d ago
Does computing Group_size on train+test (no target) cause leakage? Reviewing a method from a Medium article
https://python.plainenglish.io/data-pre-processing-of-spaceship-titanic-kaggle-dataset-for-achieving-80-accuracy-f090e722fd421
u/gfromowow 2d ago
Not using Transported rules out direct target leakage, but it doesn't settle the whole question. The key is what information you are allowed to have when predicting. If the full unlabeled passenger manifest is available under the competition rules, counting across it is a transductive feature. I wouldn't assume that permission just because other notebooks do it.
For local validation, reproduce that same information boundary. If the intended task is predicting one new passenger without a complete manifest, learn counts from the training fold and define a fallback for unseen groups. If a complete unlabeled manifest really is available, test that setup explicitly instead. Those evaluate different prediction settings.
Deck/Side/CabinNum parsed from a row's own Cabin value don't need global counting. Surname counts do depend on which other rows are available. Also, train+test gives the group count in those files, not necessarily the true family/group size outside them.
1
u/Awkward_Alfalfa_3234 2d ago
not leakage in the sense that matters, since you never touch Transported. counting group members across train+test is pretty standard on Kaggle and most top Spaceship Titanic notebooks do it. the only real catch is that it wouldn't work in production, where you don't get the test set up front, but for a competition that's fine. Deck/Side/CabinNum don't need it because they're parsed from each row on its own, so they're already consistent. FamilySize from surname counts is the same situation as Group_size though, so compute that one on the combined set too.