TimeSeriesCloudPredictor.fit_predict

TimeSeriesCloudPredictor.fit_predict(train_data: str | DataFrame, *, predictor_init_args: Dict[str, Any], predictor_fit_args: Dict[str, Any] | None = None, known_covariates: str | DataFrame | None = None, id_column: str = 'item_id', timestamp_column: str = 'timestamp', static_features: str | DataFrame | None = None, framework_version: str = 'latest', job_name: str | None = None, instance_type: str = 'ml.m5.2xlarge', instance_count: int = 1, volume_size: int = 100, custom_image_uri: str | None = None, wait: bool = True, predictions_path: str | None = None, backend_kwargs: Dict | None = None) DataFrame | None[source]

Fit and predict in a single SageMaker training job.

This is useful for foundation-model forecasting workflows (e.g. Chronos-2) where “fit” is essentially loading a pretrained model. Running fit and predict in the same job avoids the SageMaker startup overhead twice.

Predictions are generated inside the training container against train_data (the standard time-series forecasting flow where the last prediction_length steps of each series are forecast) and written directly to S3.

Parameters:
  • train_data (Union[str, pd.DataFrame]) – The historical time-series data to train on and forecast from. Either a pandas DataFrame or a local / S3 path to a data file (CSV or Parquet).

  • predictor_init_args (dict) – Init args for the predictor (must include prediction_length).

  • predictor_fit_args (Optional[dict], default = None) – Additional fit args for the predictor. Must not contain a train_data key — pass train_data as the explicit argument above.

  • known_covariates (Optional[Union[str, pd.DataFrame]], default = None) – Values of the known covariates for each time series during the forecast horizon. Either a pandas DataFrame or a local / S3 path to a data file (CSV or Parquet). Forwarded to TimeSeriesPredictor.predict in the container. For details, see: https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesPredictor.predict.html

  • id_column (str, default = "item_id") – Name of the item ID column.

  • timestamp_column (str, default = "timestamp") – Name of the timestamp column.

  • static_features (Optional[pd.DataFrame]) – Optional metadata attributes per item.

  • framework_version

  • job_name

  • instance_type

  • instance_count

  • volume_size

  • custom_image_uri

  • wait

:param : :param backend_kwargs: Same semantics as fit(). :param predictions_path: S3 URL where predictions will be written by the training container (e.g.

s3://my-bucket/runs/2024-05-01/predictions.csv). The container’s SageMaker execution role must have s3:PutObject permission for this location. Defaults to {cloud_output_path}/{job_name}/predictions.csv. Predictions use AutoGluon’s canonical column names item_id and timestamp, regardless of the id_column / timestamp_column passed in.

Returns:

Predictions as a DataFrame. Returns None when wait is False.

Return type:

Optional[pd.DataFrame]