Skip to content
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

[timeseries] Fix prediction failing if context contains < 3 observations #4070

Conversation

shchur
Copy link
Collaborator

@shchur shchur commented Apr 9, 2024

Description of changes:

  • Many models currently rely on data.freq of the data passed to model.predict(data) when generating the forecast. It may happen that some time series in data passed to predict contain just a single observation. In this case, freq inference is impossible and the model fails.
  • With this PR, we
    1. Rely on self.freq attribute of the model instead of data.freq whenever frequency is required
    2. Make sure that data.fill_missing_values() works even no freq is available (as this is too strong of a requirement for this method)

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

@shchur shchur requested a review from canerturkmen April 9, 2024 14:45
@yinweisu
Copy link
Collaborator

yinweisu commented Apr 9, 2024

Previous CI Run Current CI Run

2 similar comments
@yinweisu
Copy link
Collaborator

yinweisu commented Apr 9, 2024

Previous CI Run Current CI Run

@yinweisu
Copy link
Collaborator

yinweisu commented Apr 9, 2024

Previous CI Run Current CI Run

@shchur shchur force-pushed the fix-prediction-failing-if-series-have-one-observation branch from f309903 to a3d0bc4 Compare April 9, 2024 19:23
@yinweisu
Copy link
Collaborator

yinweisu commented Apr 9, 2024

Previous CI Run Current CI Run

Copy link

github-actions bot commented Apr 9, 2024

Job PR-4070-a3d0bc4 is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-4070/a3d0bc4/index.html

Copy link
Contributor

@canerturkmen canerturkmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks! Just one question.

@@ -234,13 +234,6 @@ def _get_hpo_backend(self):

def _deferred_init_params_aux(self, dataset: TimeSeriesDataFrame) -> None:
"""Update GluonTS specific parameters with information available only at training time."""
self.freq = dataset.freq or self.freq
if not self.freq:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1/ Why remove self.freq = dataset.freq or self.freq? We never depend on deferred initialization for freq in any other model? Is freq always set for all models by the trainer?
2/ Why remove this assertion? maybe assert self.freq?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. No other model currently depends on deferred initialization of freq (both local & MLForecast models assume that freq is provided at creation time); trainer always sets freq when creating models (https://github.com/autogluon/autogluon/blob/master/timeseries/src/autogluon/timeseries/trainer/abstract_trainer.py#L576)
  2. Assuming you are referring to the assertion inside SimpleGluonTSDataset.__init__: after pandas 2.2 upgrade, we will anyway need to remove this part completely and always feed a dummy frequency W to GluonTS. So the assertion would be removed anyway after [WIP] Upgrade pandas to 2.2 #4074 is merged.

@shchur shchur merged commit c27c935 into autogluon:master Apr 10, 2024
29 checks passed
@shchur shchur deleted the fix-prediction-failing-if-series-have-one-observation branch April 10, 2024 10:10
LennartPurucker pushed a commit to LennartPurucker/autogluon that referenced this pull request Jun 1, 2024
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.

None yet

3 participants