NCA-ADS - Advanced Data Structures - Section 7.1

Handle time-series data.

Handle time-series data by preserving temporal order, engineering lag features and rolling statistics, and avoiding future data leakage in train/test splits. Recognise seasonal decomposition and stationarity as prerequisites for many forecasting approaches.

Practice question for this objective

Free sampleAdvanced Data Structuresmedium

A data scientist is building a GPU-accelerated model to forecast next week's demand from historical daily sales held in a cuDF DataFrame with a datetime column. To estimate how the model will perform on genuinely future data, how should the train and test sets be split?

  • AUse the earliest dates for training and the most recent dates for testing, splitting on a cut-off timestamp so the test period strictly follows the training period. Correct
  • BShuffle all rows randomly and assign 80 per cent to training and 20 per cent to testing, so both sets cover the full date range evenly.
  • CApply stratified sampling on the daily_sales value so that the train and test sets share the same distribution of sales magnitudes.
  • DHold out every seventh day as the test set so that each weekday appears in both training and testing in equal proportion.
Time-series forecasting must use a chronological train/test split so the test period strictly follows the training period and no future data leaks backward. Because each observation depends on time order, a random split lets the model see future-dated rows during training and then evaluate on earlier rows, producing an optimistic estimate that does not reflect true forward prediction; a cut-off-based split preserves the past-predicts-future structure of deployment.

Why A is correct: Splitting on a chronological cut-off keeps all training rows earlier than every test row, which mirrors the real deployment scenario of predicting the future from the past and prevents look-ahead leakage.

Why B is wrong: A uniform random shuffle is the default for non-temporal data, but for forecasting it places future-dated rows in the training set and past-dated rows in the test set, leaking future information and inflating the score.

Why C is wrong: Stratifying on the target balances sales magnitudes across splits, which is useful for imbalanced classification, but it ignores time ordering and still mixes future and past rows across the two sets.

Why D is wrong: Interleaving days by weekday seems to control for day-of-week seasonality, but it scatters test rows throughout the training period, again letting the model train on data that comes after the rows it is evaluated on.

See more NCA-ADS practice questions, answers explained.

More in this domain

Back to all Advanced Data Structures objectives, or the NCA-ADS cert hub.

Examworthy is not affiliated with or endorsed by NVIDIA. Original, blueprint-aligned practice material only.