Skip to content

[timeseries] Accept seasonal_period in TimeSeriesScorer.__call__ with a deprecation warning - #5957

Merged
shchur merged 1 commit into
autogluon:masterfrom
nicoloangileri:fix/scorer-seasonal-period-deprecation
Nov 10, 2026
Merged

shchur merged 1 commit into
autogluon:masterfrom
nicoloangileri:fix/scorer-seasonal-period-deprecation

Conversation

@nicoloangileri

Copy link
Copy Markdown
Contributor

Issue #, if available: none

Description of changes:

#5084 (horizon weights) moved both prediction_length and seasonal_period from TimeSeriesScorer.__call__ to the constructor. Passing prediction_length to __call__ still works and emits a FutureWarning. Passing seasonal_period there, as code written for earlier versions does, now fails with an error that doesn't point at the cause:

from autogluon.timeseries.metrics import MASE

MASE(prediction_length=5)(data, predictions, seasonal_period=3)
# TypeError: MASE.save_past_metrics() got multiple values for keyword argument 'seasonal_period'

This happens because seasonal_period stays in **kwargs and reaches save_past_metrics() next to the explicit seasonal_period= argument.

This PR handles it the same way as prediction_length: it emits a FutureWarning ("deprecated and will be removed in v2.0"), sets self.seasonal_period, and removes the key from kwargs. The result is the same as constructing the metric with seasonal_period=....

Tests:

  • New test_when_seasonal_period_passed_to_call_then_warning_is_raised_and_value_matches_init for MASE, RMSSE and SQL. It checks the warning and that the value equals the one from seasonal_period in the constructor. DUMMY_TS_DATAFRAME is hourly (default seasonality 24), so the test also fails if the argument were dropped instead of applied. On master it fails with the TypeError above.
  • timeseries/tests/unittests/test_metrics.py: 268 passed. ruff check and ruff format --check pass.

While checking this I also compared MAE, MSE, RMSE, MAPE, SMAPE, WAPE, MASE, RMSSE, WQL, SQL and MQL against their documented formulas on series with missing past values and a seasonal period of 3, and all of them matched.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nicoloangileri

Copy link
Copy Markdown
Contributor Author

Hi @shchur, a gentle ping on this one when you have a moment. It restores seasonal_period in TimeSeriesScorer.__call__ with a deprecation warning, so existing calls keep working. Happy to adjust anything. Thanks!

@nicoloangileri

Copy link
Copy Markdown
Contributor Author

Hi @shchur @Innixma, following up on this one when you have a moment. It restores seasonal_period in TimeSeriesScorer.__call__ with a deprecation warning, so existing custom metrics keep working. It merges cleanly and CI is green. Happy to adjust anything. Thanks!

@nicoloangileri

Copy link
Copy Markdown
Contributor Author

Hi @shchur, checking in once more on this one. It restores seasonal_period in TimeSeriesScorer.__call__ with a deprecation warning, so existing custom metrics keep working. It still merges cleanly; the only pending check is the approval gate. Happy to adjust anything, or to close it if you'd rather handle this differently. Thanks!

@shchur
shchur force-pushed the fix/scorer-seasonal-period-deprecation branch from 1f9be07 to ce44d76 Compare November 9, 2026 17:11
@shchur

shchur commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks @nicoloangileri, will merge this after CI passes

@shchur
shchur merged commit 094ee82 into autogluon:master Nov 10, 2026
23 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

This branch was successfully deployed

1 active deployment
integration-tests — ce44d76d Deployed Nov 10, 2026 by shchur via approval_gate #12237
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.

2 participants