Skip to content

fix: raise ValueError for h>1 in forecast_fitted_values#1082

Open
GauravPatil2515 wants to merge 1 commit intoNixtla:mainfrom
GauravPatil2515:fix/issue-1032-forecast-fitted-values-h-validation
Open

fix: raise ValueError for h>1 in forecast_fitted_values#1082
GauravPatil2515 wants to merge 1 commit intoNixtla:mainfrom
GauravPatil2515:fix/issue-1032-forecast-fitted-values-h-validation

Conversation

@GauravPatil2515
Copy link

Fixes #1032

Description

This PR addresses the issue where forecast_fitted_values silently ignores multi-step expectations or behaves ambiguously when users try to generate in-sample forecasts for h > 1.

Forecast fitted values are conceptually 1-step-ahead predictions. To prevent user confusion and incorrect usage, this change makes the restriction explicit.

Changes

  • Core Logic: Updated _StatsForecast.forecast_fitted_values and StatsForecast.forecast_fitted_values to accept an h parameter (defaulting to 1).
  • Validation: Added a check to explicitly raise a ValueError if h > 1. The error message guides new users to use cross_validation or forecast() for multi-step predictions.
  • Tests: Added regression tests (tests/test_issue_1032.py) to verify:
    • h=1 works as expected (default logic preserved).
    • h>1 correctly raises ValueError.

Checklist

  • Code passes all tests
  • New tests added
  • Docstrings updated to reflect the new h parameter and ValueError

Fixes Nixtla#1032

- Add h parameter (default=1) to forecast_fitted_values
- Raise ValueError with guidance when h>1
- Add regression tests
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

forecast_fitted_values() only works with h = 1

2 participants