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', predictions_path: str | None = None, framework_version: str = '1.6', instance_type: str = 'ml.m5.2xlarge', wait: bool = True, backend_overrides: dict[str, dict[str, Any]] | None = None, **kwargs: Unpack[TrainingJobKwargs]) → DataFrame | None[source]

Fit and predict in a single SageMaker training job.

Fits a TimeSeriesPredictor on train_data and, in the same job, forecasts the next prediction_length steps after the end of each series in train_data.

Parameters:
  • train_data (str | pathlib.Path | pd.DataFrame) – Historical time series to train on and forecast from, in long format, as a pd.DataFrame or local/S3 path to a data file.

  • predictor_init_args (dict) – Arguments forwarded to TimeSeriesPredictor(). Must include prediction_length. See the TimeSeriesPredictor docs for available options.

  • predictor_fit_args (dict | None, default = None) – Additional fit args forwarded to TimeSeriesPredictor.fit(). See the TimeSeriesPredictor.fit docs for available options. Must NOT contain train_data, tuning_data, or known_covariates — pass those as explicit arguments above.

  • known_covariates (str | pathlib.Path | pd.DataFrame | None, default = None) – Future values of the known covariates over the forecast horizon. Must be provided if known_covariates_names was specified in predictor_init_args.

  • static_features (str | pathlib.Path | pd.DataFrame | None, 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.

  • predictions_path (str | None, default = None) – S3 URL of the predictions file, ending in .csv or .parquet. The SageMaker execution role must be able to write to it. Defaults to {cloud_output_path}/{job_name}/predictions.csv.

  • framework_version (str, optional) – AutoGluon version, e.g. "1.6". Training uses the official AutoGluon DLC image for this version. Ignored if custom_image_uri is set.

  • instance_type (str, default = "ml.m5.2xlarge") – Instance type of the training job.

  • wait (bool, default = True) – Whether to block until the job completes. If False, returns None once the job is launched.

Returns:

pd.DataFrame | None – Forecast in long format with item_id, timestamp, mean, and one column per quantile, or None if wait=False; fetch it later with get_fit_predict_results(). Columns are named item_id and timestamp regardless of id_column / timestamp_column.

Other Parameters:
  • backend_overrides (dict[str, dict[str, Any]] | None, default = None) – Raw SageMaker request fields for settings without a dedicated argument.

    • Keys: request names from the SageMaker API section below.

    • Values: request fields in PascalCase, as in the SageMaker API and boto3. Deep-merged over the request built by AutoGluon-Cloud; lists and other non-dict values replace the generated ones.

    • Example: {"CreateTrainingJob": {"RetryStrategy": {"MaximumRetryAttempts": 2}}}

  • job_name (str | None, default = None) – Name of the training job. Defaults to a unique name with prefix ag-cloud-timeseries.

  • volume_size (int, default = 100) – Size in GB of the EBS volume that stores the training data and model artifacts.

  • custom_image_uri (str | None, default = None) – Custom training container image URI. If set, framework_version is ignored.

  • timeout (int, default = 86400) – Maximum training job runtime in seconds. Defaults to 24 hours.

SageMaker API

  • CreateTrainingJob: trains the predictor and predicts in the same job on instance_type. Predictions are written to predictions_path.