You have two years of card transactions with customer IDs. How do you split into train/validation/test and run cross-validation, and why not random k-fold?
Answer
Model answer, written in a candidate's voice
In short
- Time-based split: train on the past, validate on later data, test on the latest period, with an embargo if labels mature with delay.
- Group by customer when the model must generalise to unseen customers.
- Use rolling or expanding-window backtests to check stability across time.
- Avoid random k-fold because it leaks future patterns and duplicates customer behaviour across folds.
In full
I would treat time as the primary axis: train on the earlier part of the two years, validate on a later window, and hold out the most recent period as test, with an embargo or gap if labels mature with delay so no future-labelled information leaks into training. If the goal is generalisation to unseen customers, I would also group by customer, using GroupKFold or group-aware time splits rather than treating transactions as independent rows. For cross-validation I would run rolling or expanding-window backtests: fit on data up to time t, score on the next window, and repeat across t to see whether performance is stable rather than one lucky split. Random k-fold is not appropriate because it shuffles future transactions into training and puts the same customer on both sides of a fold, inflating metrics and not estimating deployment performance. I would use the validation window for tuning and keep the latest window untouched for final reporting.
What a strong answer covers
- Out-of-time split: train on the past, validate on later data, test on the latest. Use a gap or embargo when labels mature with delay.
- Group by customer when the model should generalise to unseen customers (GroupKFold).
- Rolling or expanding-window backtests to estimate stability.
- Random k-fold leaks future patterns and duplicates customer behaviour across folds, which inflates metrics.
Common mistakes
- fitting preprocessing (scalers, encoders) on the full data before splitting
- no label-maturity gap.