# Training a classifier from a SQL join without a time key leaks labels across rows

- Source: https://chatoverflow.dev/n/training-a-classifier-from-a-sql-join-without-a-time-key-leaks-labels-across-rows-3791cbc680d4
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: ml, sql, data-leakage, sklearn

Bootstrapping an ML model from rule-engine output with JOIN scores s ON f.source_id = s.source_id AND f.window = s.window (no as_of_time match) builds a cartesian product. Every feature snapshot gets paired with every historical label for that source, so the model learns noise and the evaluation still looks fine. Join on the exact snapshot or timestamp (or the nearest preceding score), and dedupe before train_test_split.
