Skip to content

create_auto_predictor async

create_auto_predictor(
    predictor_name: Name,
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    forecast_horizon: Optional[Integer] = None,
    forecast_types: Optional[ForecastTypes] = None,
    forecast_dimensions: Optional[ForecastDimensions] = None,
    forecast_frequency: Optional[Frequency] = None,
    data_config: Optional[DataConfig] = None,
    encryption_config: Optional[EncryptionConfig] = None,
    reference_predictor_arn: Optional[Arn] = None,
    optimization_metric: Optional[OptimizationMetric] = None,
    explain_predictor: Optional[Boolean] = None,
    tags: Optional[Tags] = None,
    monitor_config: Optional[MonitorConfig] = None,
    time_alignment_boundary: Optional[TimeAlignmentBoundary] = None,
) -> CreateAutoPredictorResponse

Creates an Amazon Forecast predictor.

Amazon Forecast creates predictors with AutoPredictor, which involves applying the optimal combination of algorithms to each time series in your datasets. You can use CreateAutoPredictor to create new predictors or upgrade/retrain existing predictors.

Creating new predictors

The following parameters are required when creating a new predictor:

  • PredictorName - A unique name for the predictor.

  • DatasetGroupArn - The ARN of the dataset group used to train the predictor.

  • ForecastFrequency - The granularity of your forecasts (hourly, daily, weekly, etc).

  • ForecastHorizon - The number of time-steps that the model predicts. The forecast horizon is also called the prediction length.

When creating a new predictor, do not specify a value for ReferencePredictorArn.

Upgrading and retraining predictors

The following parameters are required when retraining or upgrading a predictor:

  • PredictorName - A unique name for the predictor.

  • ReferencePredictorArn - The ARN of the predictor to retrain or upgrade.

When upgrading or retraining a predictor, only specify values for the ReferencePredictorArn and PredictorName.

Parameters:

  • predictor_name (Name) –

    A unique name for the predictor

  • forecast_horizon (Optional[Integer], default: None ) –

    The number of time-steps that the model predicts. The forecast horizon is also called the prediction length.

    The maximum forecast horizon is the lesser of 500 time-steps or 1/4 of the TARGET_TIME_SERIES dataset length. If you are retraining an existing AutoPredictor, then the maximum forecast horizon is the lesser of 500 time-steps or 1/3 of the TARGET_TIME_SERIES dataset length.

    If you are upgrading to an AutoPredictor or retraining an existing AutoPredictor, you cannot update the forecast horizon parameter. You can meet this requirement by providing longer time-series in the dataset.

  • forecast_types (Optional[ForecastTypes], default: None ) –

    The forecast types used to train a predictor. You can specify up to five forecast types. Forecast types can be quantiles from 0.01 to 0.99, by increments of 0.01 or higher. You can also specify the mean forecast with mean.

  • forecast_dimensions (Optional[ForecastDimensions], default: None ) –

    An array of dimension (field) names that specify how to group the generated forecast.

    For example, if you are generating forecasts for item sales across all your stores, and your dataset contains a store_id field, you would specify store_id as a dimension to group sales forecasts for each store.

  • forecast_frequency (Optional[Frequency], default: None ) –

    The frequency of predictions in a forecast.

    Valid intervals are an integer followed by Y (Year), M (Month), W (Week), D (Day), H (Hour), and min (Minute). For example, "1D" indicates every day and "15min" indicates every 15 minutes. You cannot specify a value that would overlap with the next larger frequency. That means, for example, you cannot specify a frequency of 60 minutes, because that is equivalent to 1 hour. The valid values for each frequency are the following:

    • Minute - 1-59

    • Hour - 1-23

    • Day - 1-6

    • Week - 1-4

    • Month - 1-11

    • Year - 1

    Thus, if you want every other week forecasts, specify "2W". Or, if you want quarterly forecasts, you specify "3M".

    The frequency must be greater than or equal to the TARGET_TIME_SERIES dataset frequency.

    When a RELATED_TIME_SERIES dataset is provided, the frequency must be equal to the RELATED_TIME_SERIES dataset frequency.

  • data_config (Optional[DataConfig], default: None ) –

    The data configuration for your dataset group and any additional datasets.

  • reference_predictor_arn (Optional[Arn], default: None ) –

    The ARN of the predictor to retrain or upgrade. This parameter is only used when retraining or upgrading a predictor. When creating a new predictor, do not specify a value for this parameter.

    When upgrading or retraining a predictor, only specify values for the ReferencePredictorArn and PredictorName. The value for PredictorName must be a unique predictor name.

  • optimization_metric (Optional[OptimizationMetric], default: None ) –

    The accuracy metric used to optimize the predictor.

  • explain_predictor (Optional[Boolean], default: None ) –

    Create an Explainability resource for the predictor.

  • tags (Optional[Tags], default: None ) –

    Optional metadata to help you categorize and organize your predictors. Each tag consists of a key and an optional value, both of which you define. Tag keys and values are case sensitive.

    The following restrictions apply to tags:

    • For each resource, each tag key must be unique and each tag key must have one value.

    • Maximum number of tags per resource: 50.

    • Maximum key length: 128 Unicode characters in UTF-8.

    • Maximum value length: 256 Unicode characters in UTF-8.

    • Accepted characters: all letters and numbers, spaces representable in UTF-8, and + - = . _ : / @. If your tagging schema is used across other services and resources, the character restrictions of those services also apply.

    • Key prefixes cannot include any upper or lowercase combination of aws: or AWS:. Values can have this prefix. If a tag value has aws as its prefix but the key does not, Forecast considers it to be a user tag and will count against the limit of 50 tags. Tags with only the key prefix of aws do not count against your tags per resource limit. You cannot edit or delete tag keys with this prefix.

  • monitor_config (Optional[MonitorConfig], default: None ) –

    The configuration details for predictor monitoring. Provide a name for the monitor resource to enable predictor monitoring.

    Predictor monitoring allows you to see how your predictor's performance changes over time. For more information, see Predictor Monitoring.

  • time_alignment_boundary (Optional[TimeAlignmentBoundary], default: None ) –

    The time boundary Forecast uses to align and aggregate any data that doesn't align with your forecast frequency. Provide the unit of time and the time boundary as a key value pair. For more information on specifying a time boundary, see Specifying a Time Boundary. If you don't provide a time boundary, Forecast uses a set of Default Time Boundaries.

Raises:

Source code in docs_src/capo_forecast/_services/async_forecast.py
async def create_auto_predictor(
    self,
    predictor_name: "capo_forecast.types.name.Name",
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    forecast_horizon: Optional["capo_forecast.types.integer.Integer"] = None,
    forecast_types: Optional[
        "capo_forecast.types.forecast_types.ForecastTypes"
    ] = None,
    forecast_dimensions: Optional[
        "capo_forecast.types.forecast_dimensions.ForecastDimensions"
    ] = None,
    forecast_frequency: Optional["capo_forecast.types.frequency.Frequency"] = None,
    data_config: Optional["capo_forecast.types.data_config.DataConfig"] = None,
    encryption_config: Optional[
        "capo_forecast.types.encryption_config.EncryptionConfig"
    ] = None,
    reference_predictor_arn: Optional["capo_forecast.types.arn.Arn"] = None,
    optimization_metric: Optional[
        "capo_forecast.types.optimization_metric.OptimizationMetric"
    ] = None,
    explain_predictor: Optional["capo_forecast.types.boolean.Boolean"] = None,
    tags: Optional["capo_forecast.types.tags.Tags"] = None,
    monitor_config: Optional[
        "capo_forecast.types.monitor_config.MonitorConfig"
    ] = None,
    time_alignment_boundary: Optional[
        "capo_forecast.types.time_alignment_boundary.TimeAlignmentBoundary"
    ] = None,
) -> (
    "capo_forecast.types.create_auto_predictor_response.CreateAutoPredictorResponse"
):
    """<p>Creates an Amazon Forecast predictor.</p> <p>Amazon Forecast creates predictors with AutoPredictor, which involves applying the optimal combination of algorithms to each time series in your datasets. You can use <a>CreateAutoPredictor</a> to create new predictors or upgrade/retrain existing predictors.</p> <p> <b>Creating new predictors</b> </p> <p>The following parameters are required when creating a new predictor:</p> <ul> <li> <p> <code>PredictorName</code> - A unique name for the predictor.</p> </li> <li> <p> <code>DatasetGroupArn</code> - The ARN of the dataset group used to train the predictor.</p> </li> <li> <p> <code>ForecastFrequency</code> - The granularity of your forecasts (hourly, daily, weekly, etc).</p> </li> <li> <p> <code>ForecastHorizon</code> - The number of time-steps that the model predicts. The forecast horizon is also called the prediction length.</p> </li> </ul> <p>When creating a new predictor, do not specify a value for <code>ReferencePredictorArn</code>.</p> <p> <b>Upgrading and retraining predictors</b> </p> <p>The following parameters are required when retraining or upgrading a predictor:</p> <ul> <li> <p> <code>PredictorName</code> - A unique name for the predictor.</p> </li> <li> <p> <code>ReferencePredictorArn</code> - The ARN of the predictor to retrain or upgrade.</p> </li> </ul> <p>When upgrading or retraining a predictor, only specify values for the <code>ReferencePredictorArn</code> and <code>PredictorName</code>. </p>

    Args:
        predictor_name: <p>A unique name for the predictor</p>
        forecast_horizon: <p>The number of time-steps that the model predicts. The forecast horizon is also called the prediction length.</p> <p>The maximum forecast horizon is the lesser of 500 time-steps or 1/4 of the TARGET_TIME_SERIES dataset length. If you are retraining an existing AutoPredictor, then the maximum forecast horizon is the lesser of 500 time-steps or 1/3 of the TARGET_TIME_SERIES dataset length.</p> <p>If you are upgrading to an AutoPredictor or retraining an existing AutoPredictor, you cannot update the forecast horizon parameter. You can meet this requirement by providing longer time-series in the dataset.</p>
        forecast_types: <p>The forecast types used to train a predictor. You can specify up to five forecast types. Forecast types can be quantiles from 0.01 to 0.99, by increments of 0.01 or higher. You can also specify the mean forecast with <code>mean</code>.</p>
        forecast_dimensions: <p>An array of dimension (field) names that specify how to group the generated forecast.</p> <p>For example, if you are generating forecasts for item sales across all your stores, and your dataset contains a <code>store_id</code> field, you would specify <code>store_id</code> as a dimension to group sales forecasts for each store.</p>
        forecast_frequency: <p>The frequency of predictions in a forecast.</p> <p>Valid intervals are an integer followed by Y (Year), M (Month), W (Week), D (Day), H (Hour), and min (Minute). For example, "1D" indicates every day and "15min" indicates every 15 minutes. You cannot specify a value that would overlap with the next larger frequency. That means, for example, you cannot specify a frequency of 60 minutes, because that is equivalent to 1 hour. The valid values for each frequency are the following:</p> <ul> <li> <p>Minute - 1-59</p> </li> <li> <p>Hour - 1-23</p> </li> <li> <p>Day - 1-6</p> </li> <li> <p>Week - 1-4</p> </li> <li> <p>Month - 1-11</p> </li> <li> <p>Year - 1</p> </li> </ul> <p>Thus, if you want every other week forecasts, specify "2W". Or, if you want quarterly forecasts, you specify "3M".</p> <p>The frequency must be greater than or equal to the TARGET_TIME_SERIES dataset frequency.</p> <p>When a RELATED_TIME_SERIES dataset is provided, the frequency must be equal to the RELATED_TIME_SERIES dataset frequency.</p>
        data_config: <p>The data configuration for your dataset group and any additional datasets.</p>
        reference_predictor_arn: <p>The ARN of the predictor to retrain or upgrade. This parameter is only used when retraining or upgrading a predictor. When creating a new predictor, do not specify a value for this parameter.</p> <p>When upgrading or retraining a predictor, only specify values for the <code>ReferencePredictorArn</code> and <code>PredictorName</code>. The value for <code>PredictorName</code> must be a unique predictor name.</p>
        optimization_metric: <p>The accuracy metric used to optimize the predictor.</p>
        explain_predictor: <p>Create an Explainability resource for the predictor.</p>
        tags: <p>Optional metadata to help you categorize and organize your predictors. Each tag consists of a key and an optional value, both of which you define. Tag keys and values are case sensitive.</p> <p>The following restrictions apply to tags:</p> <ul> <li> <p>For each resource, each tag key must be unique and each tag key must have one value.</p> </li> <li> <p>Maximum number of tags per resource: 50.</p> </li> <li> <p>Maximum key length: 128 Unicode characters in UTF-8.</p> </li> <li> <p>Maximum value length: 256 Unicode characters in UTF-8.</p> </li> <li> <p>Accepted characters: all letters and numbers, spaces representable in UTF-8, and + - = . _ : / @. If your tagging schema is used across other services and resources, the character restrictions of those services also apply. </p> </li> <li> <p>Key prefixes cannot include any upper or lowercase combination of <code>aws:</code> or <code>AWS:</code>. Values can have this prefix. If a tag value has <code>aws</code> as its prefix but the key does not, Forecast considers it to be a user tag and will count against the limit of 50 tags. Tags with only the key prefix of <code>aws</code> do not count against your tags per resource limit. You cannot edit or delete tag keys with this prefix.</p> </li> </ul>
        monitor_config: <p>The configuration details for predictor monitoring. Provide a name for the monitor resource to enable predictor monitoring.</p> <p>Predictor monitoring allows you to see how your predictor's performance changes over time. For more information, see <a href="https://docs.aws.amazon.com/forecast/latest/dg/predictor-monitoring.html">Predictor Monitoring</a>.</p>
        time_alignment_boundary: <p>The time boundary Forecast uses to align and aggregate any data that doesn't align with your forecast frequency. Provide the unit of time and the time boundary as a key value pair. For more information on specifying a time boundary, see <a href="https://docs.aws.amazon.com/forecast/latest/dg/data-aggregation.html#specifying-time-boundary">Specifying a Time Boundary</a>. If you don't provide a time boundary, Forecast uses a set of <a href="https://docs.aws.amazon.com/forecast/latest/dg/data-aggregation.html#default-time-boundaries">Default Time Boundaries</a>.</p>

    Raises:
        capo_forecast.errors.invalid_input_exception.InvalidInputException: <p>We can't process the request because it includes an invalid value or a value that exceeds the valid range.</p>
        capo_forecast.errors.limit_exceeded_exception.LimitExceededException: <p>The limit on the number of resources per account has been exceeded.</p>
        capo_forecast.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>There is already a resource with this name. Try again with a different name.</p>
        capo_forecast.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is in use.</p>
        capo_forecast.errors.resource_not_found_exception.ResourceNotFoundException: <p>We can't find a resource with that Amazon Resource Name (ARN). Check the ARN and try again.</p>
        capo_forecast.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_forecast.types.create_auto_predictor_request.CreateAutoPredictorRequest]",
    ) -> AsyncOperationResponse[
        "capo_forecast.types.create_auto_predictor_response.CreateAutoPredictorResponse"
    ]:
        import capo_forecast._operations.amazon_forecast.create_auto_predictor

        (
            output,
            http_response,
        ) = await capo_forecast._operations.amazon_forecast.create_auto_predictor.async_create_auto_predictor(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_forecast.types.create_auto_predictor_request.CreateAutoPredictorRequest",
    ) -> dict[str, Any]:
        import capo_forecast.types.create_auto_predictor_request

        return capo_forecast.types.create_auto_predictor_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateAutoPredictor", redact_input=_redact_input),
    )
    input_: capo_forecast.types.create_auto_predictor_request.CreateAutoPredictorRequest = {
        "predictor_name": predictor_name
    }
    if forecast_horizon is not None:
        input_["forecast_horizon"] = forecast_horizon
    if forecast_types is not None:
        input_["forecast_types"] = forecast_types
    if forecast_dimensions is not None:
        input_["forecast_dimensions"] = forecast_dimensions
    if forecast_frequency is not None:
        input_["forecast_frequency"] = forecast_frequency
    if data_config is not None:
        input_["data_config"] = data_config
    if encryption_config is not None:
        input_["encryption_config"] = encryption_config
    if reference_predictor_arn is not None:
        input_["reference_predictor_arn"] = reference_predictor_arn
    if optimization_metric is not None:
        input_["optimization_metric"] = optimization_metric
    if explain_predictor is not None:
        input_["explain_predictor"] = explain_predictor
    if tags is not None:
        input_["tags"] = tags
    if monitor_config is not None:
        input_["monitor_config"] = monitor_config
    if time_alignment_boundary is not None:
        input_["time_alignment_boundary"] = time_alignment_boundary

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output