TimeSeriesCloudPredictor.fit_predict¶
- TimeSeriesCloudPredictor.fit_predict(train_data: str | Path | DataFrame, *, known_covariates: str | Path | DataFrame | None = None, static_features: str | Path | DataFrame | None = None, predictor_init_args: Dict[str, Any], predictor_fit_args: Dict[str, Any] | None = None, id_column: str = 'item_id', timestamp_column: str = 'timestamp', 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 lastprediction_lengthsteps of each series are forecast) and written directly to S3.- Parameters:
train_data (Union[str, pathlib.Path, pd.DataFrame]) – Historical time-series data to train on and forecast from, as a DataFrame or local/S3 path to a data file.
known_covariates (Optional[Union[str, pathlib.Path, pd.DataFrame]], default = None) – Values of the known covariates for each time series during the forecast horizon. Forwarded to
TimeSeriesPredictor.predictin the container. For details, see: https://auto.gluon.ai/stable/api/autogluon.timeseries.TimeSeriesPredictor.predict.htmlstatic_features (Optional[Union[str, pathlib.Path, pd.DataFrame]], default = None) – Optional metadata attributes per item.
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
train_data,tuning_data, orknown_covariates— pass those as explicit arguments above.id_column (str, default = "item_id") – Name of the item ID column.
timestamp_column (str, default = "timestamp") – Name of the timestamp column.
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 haves3:PutObjectpermission for this location. Defaults to{cloud_output_path}/{job_name}/predictions.csv. Predictions use AutoGluon’s canonical column namesitem_idandtimestamp, regardless of theid_column/timestamp_columnpassed in.- Returns:
Predictions as a DataFrame. Returns
Nonewhenwaitis False.- Return type:
Optional[pd.DataFrame]