SDE & MLE Prep

Train / Validation / Test, Cross-Validation & Leakage

Q: How do you set up evaluation so the numbers are trustworthy?

  • Train to fit, validation to tune hyperparameters/early stopping, test touched once for the final estimate.
  • k-fold CV for small data: average over k train/validate splits. Stratify for imbalanced labels; group k-fold when samples are correlated (same user); time-based splits for temporal data (never train on the future).
  • Data leakage = information unavailable at prediction time sneaks into training: target-derived features, normalizing using statistics of the full dataset, duplicate users across splits, future data. Symptom: offline metrics that are "too good" and collapse in production.