---
title: You have two years of card transactions with customer IDs. How do you split into train/validation/test and run…
url: https://gurkanozkan.ai/learn/questions/mle-validation-schemes-for-temporal-or-grouped-data-07/
markdown: https://gurkanozkan.ai/learn/questions/mle-validation-schemes-for-temporal-or-grouped-data-07.md
kind: question
role: ML engineering
stage: Technical
difficulty: Medium
json: https://gurkanozkan.ai/api/learn/questions/mle-validation-schemes-for-temporal-or-grouped-data-07.json
robots: noindex
---

# 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?

ML engineering · Technical · Medium

Theme reported publicly: [Monzo](https://monzo.com/blog/interviewing-for-machine-learning-at-monzo), [Deliveroo](https://careers.deliveroo.co.uk/interview-guide-for-machine-learning-engineer/)

## 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.

*Checked against sources by an independent AI reviewer.*

## 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.

## Topic guides

- [Classical machine learning](https://gurkanozkan.ai/learn/topics/classical-ml.md)
- [Evaluation: metrics, evals for LLM systems and statistical rigour](https://gurkanozkan.ai/learn/topics/evaluation.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
