Standard k fold splits rows randomly into k parts, training on k minus one and validating on the held out fold, then averaging. With time series that is invalid, because random splits let the model train on the future and predict the past. Use forward chaining instead: train on everything up to time t, validate on the next window, roll forward, and leave a gap if features use trailing windows.
Why interviewers ask this
Leakage through time is one of the most common reasons a model looks great offline and dies in production, so interviewers use this to see whether you think about how the model will actually be used. They also listen for grouped splitting when rows are not independent, for example multiple rows per customer, and for whether you fit preprocessing inside the fold rather than on the whole dataset.
How to structure your answer
- Describe plain k fold in one sentence.
- Explain why random splits leak when time matters.
- Describe forward chaining and the gap between train and validation.
- Add grouped splits for repeated entities and fold level preprocessing.
Example answer
Normal k fold shuffles rows into folds and rotates which one you hold out. That is fine when rows are independent, and it falls apart the moment they are not. With time series I use forward chaining: train on months one through six, validate on seven, then train through seven and validate on eight, and so on. Validation always sits after the training window, which matches how the model gets used. I also leave a gap when my features use trailing windows, because a thirty day rolling average computed right at the boundary quietly contains information from the validation period. The other trap is repeated entities. If one customer has forty rows and they land in both train and validation, the model can memorize that customer and the score is inflated, so I group by customer ID. And I fit scalers and encoders inside each fold, never on the full dataset first, because fitting on everything leaks the validation distribution into training. That one alone has explained a couple of points of drop between offline and live for me.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How many folds do you use, and why?
- What is nested cross validation and when do you need it?
- How would you validate a model that predicts a rare event a few times a year?
Related data scientist questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions