Leakage Beyond Obvious Columns

The boundary can leak through preparation

Preprocessing leakage happens when statistics from held-out data influence training - fitting a scaler, median imputer, feature selector, or Principal Component Analysis (PCA) transform before splitting. Duplicate leakage happens when near-identical records appear on both sides, letting the model recognize an example rather than generalize.

# Wrong: scaler learns test-set mean and spread
X_scaled = scaler.fit_transform(X)
X_train, X_test = train_test_split(X_scaled)

# Right: split raw rows, then fit through a Pipeline on training only
X_train, X_test = train_test_split(X)
pipe.fit(X_train, y_train)
pipe.score(X_test, y_test)

Leakage can also cross groups: two images of the same object, multiple messages from one conversation, or repeated measurements of one patient. Random row splits place related material on both sides unless group identities are respected.

Warning: Removing an obvious target column is not a complete leakage audit. Derived fields, timestamps, aggregate windows, preprocessing state, duplicates, and joins can all smuggle future or held-out information into training.
Analogy: A sealed exam is compromised not only when the answer sheet is copied. A tutor who has seen the exam and chooses exactly which topics to teach has leaked information too.