Skip to content

Implement MultiHorizonTimeSeriesSplit for multi-horizon CV #31489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrelrodriguess
Copy link

Co-authored-by: Joao Barros joao.f.barros@tecnico.ulisboa.pt

Reference Issues/PRs

Implements #31344.

What does this implement/fix? Explain your changes.

This implements a new class, MultiHorizonTimeSeriesSplit, to enhance time series cross-validation by supporting multiple prediction horizons per split.
The existing TimeSeriesSplit class is limited to generating a single, contiguous test set per split, which is insufficient for scenarios requiring forecasts over multiple future steps (e.g., predicting 1, 3, and 5 days ahead).
This new class addresses that limitation by enabling users to evaluate time series models across various forecast horizons in a single, streamlined workflow.

Here’s a breakdown of the modifications:

  • Added MultiHorizonTimeSeriesSplit as a subclass of TimeSeriesSplit.
  • Introduced a horizons parameter (a list of positive integers) to specify the prediction steps for the test sets.
  • Modified the split method to generate test indices based on the provided horizons.
  • Added checks to ensure horizons is a non-empty list of positive integers and that the input data length supports the specified horizons and number of splits.
  • Created tests to verify the correctness of splits across different configurations (e.g., varying horizons, gaps, and test sizes).

Any other comments?

Add class MultiHorizonTimeSeriesSplit to support multiple forecast
horizons per split.
Co-authored-by: Joao Barros <joao.f.barros@tecnico.ulisboa.pt>
Copy link

github-actions bot commented Jun 5, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: e30c942. Link to the linter CI: here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant