Skip to content

Fix missing future covariates error in historical_forecasts/backtest - #3193

Open
webzuweb wants to merge 1 commit into
unit8co:masterfrom
webzuweb:fix/backtest-missing-future-covariates
Open

Fix missing future covariates error in historical_forecasts/backtest#3193
webzuweb wants to merge 1 commit into
unit8co:masterfrom
webzuweb:fix/backtest-missing-future-covariates

Conversation

@webzuweb

Copy link
Copy Markdown

Summary

Fixes #2846.

When a model is trained with past/future covariates and then passed to historical_forecasts()/backtest() without the corresponding covariates, the user currently gets a cryptic IndexError: index 1 is out of bounds for axis 0 with size 1.

This PR adds an explicit ValueError (mirroring the existing check in predict()) that clearly states which covariates are missing.

Changes

  • darts/models/forecasting/forecasting_model.py: added early covariate checks in historical_forecasts().
  • darts/tests/models/forecasting/test_backtesting.py: added test_backtest_missing_future_covariates.

Test

pytest darts/tests/models/forecasting/test_backtesting.py::TestBacktesting::test_backtest_missing_future_covariates — passed.

Raise a clear ValueError when a model trained with past/future
covariates is passed to historical_forecasts()/backtest() without the
corresponding covariates, instead of a cryptic IndexError.

Closes unit8co#2846
@webzuweb
webzuweb requested a review from dennisbader as a code owner August 28, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message when future covariates are missing during backtest() call

1 participant