Skip to content

Enable known_covariates in TimeSeriesCloudPredictor.predict_real_time #181

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

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/autogluon/cloud/backend/timeseries_sagemaker_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def predict_real_time(
static_features: Optional[pd.DataFrame]
An optional data frame describing the metadata attributes of individual items in the item index.
For more detail, please refer to `TimeSeriesDataFrame` documentation:
https://auto.gluon.ai/stable/api/autogluon.predictor.html#timeseriesdataframe
https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesDataFrame.html
target: str
Name of column that contains the target values to forecast
accept: str, default = application/x-parquet
Expand Down Expand Up @@ -225,7 +225,7 @@ def predict(
static_features: Optional[Union[str, pd.DataFrame]]
An optional data frame describing the metadata attributes of individual items in the item index.
For more detail, please refer to `TimeSeriesDataFrame` documentation:
https://auto.gluon.ai/stable/api/autogluon.predictor.html#timeseriesdataframe
https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesDataFrame.html
target: str
Name of column that contains the target values to forecast
kwargs:
Expand Down
16 changes: 13 additions & 3 deletions src/autogluon/cloud/predictor/timeseries_cloud_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def fit(
static_features: Optional[pd.DataFrame]
An optional data frame describing the metadata attributes of individual items in the item index.
For more detail, please refer to `TimeSeriesDataFrame` documentation:
https://auto.gluon.ai/stable/api/autogluon.predictor.html#timeseriesdataframe
https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesDataFrame.html
framework_version: str, default = `latest`
Training container version of autogluon.
If `latest`, will use the latest available container version.
Expand Down Expand Up @@ -159,6 +159,7 @@ def predict_real_time(
self,
test_data: Union[str, pd.DataFrame],
static_features: Optional[Union[str, pd.DataFrame]] = None,
known_covariates: Optional[pd.DataFrame] = None,
accept: str = "application/x-parquet",
**kwargs,
) -> pd.DataFrame:
Expand All @@ -175,7 +176,12 @@ def predict_real_time(
static_features: Optional[pd.DataFrame]
An optional data frame describing the metadata attributes of individual items in the item index.
For more detail, please refer to `TimeSeriesDataFrame` documentation:
https://auto.gluon.ai/stable/api/autogluon.predictor.html#timeseriesdataframe
https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesDataFrame.html
known_covariates : Optional[pd.DataFrame]
If ``known_covariates_names`` were specified when creating the predictor, it is necessary to provide the
values of the known covariates for each time series during the forecast horizon.
For more details, please refer to the `TimeSeriesPredictor.predictor` documentation:
https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesPredictor.predict.html
accept: str, default = application/x-parquet
Type of accept output content.
Valid options are application/x-parquet, text/csv, application/json
Expand All @@ -198,6 +204,7 @@ def predict_real_time(
target=self.target_column,
static_features=static_features,
accept=accept,
inference_kwargs=dict(known_covariates=known_covariates, **kwargs),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I validated that this works locally but couldn't update the unit tests because currently known_covariates can only work with real-time prediction (and not batch prediction). One possible solution would be to train two predictors: one that expects known_covariates and one that doesn't, but I think that would be too much of an overhead.

Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to revisit this PR #113 for batch prediction support.

)

def predict_proba_real_time(self, **kwargs) -> pd.DataFrame:
Expand All @@ -224,6 +231,9 @@ def predict(
This method would first create a AutoGluonSagemakerInferenceModel with the trained predictor,
then create a transformer with it, and call transform in the end.

Note that batch prediction with `known_covariates` is currently not supported. Please use `predict_real_time`
to predict with `known_covariates` instead.

Parameters
----------
test_data: str
Expand All @@ -232,7 +242,7 @@ def predict(
static_features: Optional[Union[str, pd.DataFrame]]
An optional data frame describing the metadata attributes of individual items in the item index.
For more detail, please refer to `TimeSeriesDataFrame` documentation:
https://auto.gluon.ai/stable/api/autogluon.predictor.html#timeseriesdataframe
https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesDataFrame.html
target: str
Name of column that contains the target values to forecast
predictor_path: str
Expand Down
Loading