fit_predict¶
- TimeSeriesCloudPredictor.fit_predict(train_data: str | Path | DataFrame, *, predictor_init_args: Dict[str, Any], predictor_fit_args: Dict[str, Any] | None = None, known_covariates: str | Path | DataFrame | None = None, static_features: str | Path | DataFrame | 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 to train on and forecast from, in long format, as a DataFrame or local/S3 path to a data file.
predictor_init_args (dict) – Arguments forwarded to
TimeSeriesPredictor(). Must includeprediction_length. See the TimeSeriesPredictor docs for available options.predictor_fit_args (Optional[dict], default = None) – Additional fit args forwarded to
TimeSeriesPredictor.fit(). See the TimeSeriesPredictor.fit docs for available options. Must NOT containtrain_data,tuning_data, orknown_covariates— pass those as explicit arguments above.known_covariates (Optional[Union[str, pathlib.Path, pd.DataFrame]], default = None) – Future values of the known covariates over the forecast horizon. Must be provided if
known_covariates_nameswas specified inpredictor_init_args.static_features (Optional[Union[str, pathlib.Path, pd.DataFrame]], default = None) – Static (time-independent) features describing each individual time series.
id_column (str, default = "item_id") – Name of the column with the unique identifier of each time series (item).
timestamp_column (str, default = "timestamp") – Name of the column with the observation timestamps.
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]