A daily electricity-demand forecaster is tested with walk-forward validation: train on everything before a cut-off, test on the block right after it, then move the cut-off forward and do it again. The training window only ever grows.
There's one more constraint. The forecasts are needed horizon days ahead. With a horizon of , the newest value you have sits steps before the target, so in every fold the first test day sits steps after the fold's last training day. Any days in between are left out of that fold: neither trained on nor tested.
Days are numbered 0 to n - 1.
0 to first_cutoff - 1.test_size consecutive days, starting horizon steps after that fold's last training day.test_size days later, and it trains on every day before its cut-off.Task: write walk_forward_splits(n, first_cutoff, test_size, horizon=1) returning a list of tuples (train, test), where train and test are lists of day indices in increasing order. If not even one fold fits, return [].
Testing with a smaller gap than the real horizon lets each fold use fresher data than the deployed model will ever have, so the score comes out better than the model's real performance.