Skip to main content

Lesson 3 of 3 · About 5 minutes · Data leakage

Forecast with information you could have had

You want to predict next month's demand. Randomly mixing past and future months into folds can give the model information unavailable when the forecast would be made.

Try it

Choose a forecast month, then select the months used for training. Monthly demand is known only at the end of each month. Check your window, including a shorter window of past months.

What was available at forecast time?

Forecast a month's demand before that month begins. Each monthly total becomes available only at that month's end. All months shown are in the same year.

Select training months

Try including the forecast month, then try a shorter window of earlier months.

At the start of a forecast month, its final demand is still unknown. For this task, training observations and completed labels must come from earlier months. Expanding windows and fixed-length rolling windows are both valid choices to compare. A date-respecting split can still leak if a feature uses a later correction or a label that was not yet available. Evaluate the information available at prediction time, not just the row's timestamp.