Skip to content

create_predictor async

create_predictor(
    predictor_name: Name,
    forecast_horizon: Integer,
    input_data_config: InputDataConfig,
    featurization_config: FeaturizationConfig,
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    algorithm_arn: Optional[Arn] = None,
    forecast_types: Optional[ForecastTypes] = None,
    perform_auto_ml: Optional[Boolean] = None,
    auto_ml_override_strategy: Optional[AutoMLOverrideStrategy] = None,
    perform_hpo: Optional[Boolean] = None,
    training_parameters: Optional[TrainingParameters] = None,
    evaluation_parameters: Optional[EvaluationParameters] = None,
    hpo_config: Optional[HyperParameterTuningJobConfig] = None,
    encryption_config: Optional[EncryptionConfig] = None,
    tags: Optional[Tags] = None,
    optimization_metric: Optional[OptimizationMetric] = None,
) -> CreatePredictorResponse

This operation creates a legacy predictor that does not include all the predictor functionalities provided by Amazon Forecast. To create a predictor that is compatible with all aspects of Forecast, use CreateAutoPredictor.

Creates an Amazon Forecast predictor.

In the request, provide a dataset group and either specify an algorithm or let Amazon Forecast choose an algorithm for you using AutoML. If you specify an algorithm, you also can override algorithm-specific hyperparameters.

Amazon Forecast uses the algorithm to train a predictor using the latest version of the datasets in the specified dataset group. You can then generate a forecast using the CreateForecast operation.

To see the evaluation metrics, use the GetAccuracyMetrics operation.

You can specify a featurization configuration to fill and aggregate the data fields in the TARGET_TIME_SERIES dataset to improve model training. For more information, see FeaturizationConfig.

For RELATED_TIME_SERIES datasets, CreatePredictor verifies that the DataFrequency specified when the dataset was created matches the ForecastFrequency. TARGET_TIME_SERIES datasets don't have this restriction. Amazon Forecast also verifies the delimiter and timestamp format. For more information, see howitworks-datasets-groups.

By default, predictors are trained and evaluated at the 0.1 (P10), 0.5 (P50), and 0.9 (P90) quantiles. You can choose custom forecast types to train and evaluate your predictor by setting the ForecastTypes.

AutoML

If you want Amazon Forecast to evaluate each algorithm and choose the one that minimizes the objective function, set PerformAutoML to true. The objective function is defined as the mean of the weighted losses over the forecast types. By default, these are the p10, p50, and p90 quantile losses. For more information, see EvaluationResult.

When AutoML is enabled, the following properties are disallowed:

  • AlgorithmArn

  • HPOConfig

  • PerformHPO

  • TrainingParameters

To get a list of all of your predictors, use the ListPredictors operation.

Before you can use the predictor to create a forecast, the Status of the predictor must be ACTIVE, signifying that training has completed. To get the status, use the DescribePredictor operation.

Parameters:

  • predictor_name (Name) –

    A name for the predictor.

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

    The Amazon Resource Name (ARN) of the algorithm to use for model training. Required if PerformAutoML is not set to true.

    Supported algorithms:

    • arn:aws:forecast:::algorithm/ARIMA

    • arn:aws:forecast:::algorithm/CNN-QR

    • arn:aws:forecast:::algorithm/Deep_AR_Plus

    • arn:aws:forecast:::algorithm/ETS

    • arn:aws:forecast:::algorithm/NPTS

    • arn:aws:forecast:::algorithm/Prophet

  • forecast_horizon (Integer) –

    Specifies the number of time-steps that the model is trained to predict. The forecast horizon is also called the prediction length.

    For example, if you configure a dataset for daily data collection (using the DataFrequency parameter of the CreateDataset operation) and set the forecast horizon to 10, the model returns predictions for 10 days.

    The maximum forecast horizon is the lesser of 500 time-steps or 1/3 of the TARGET_TIME_SERIES dataset length.

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

    Specifies 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.

    The default value is ["0.10", "0.50", "0.9"].

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

    Whether to perform AutoML. When Amazon Forecast performs AutoML, it evaluates the algorithms it provides and chooses the best algorithm and configuration for your training dataset.

    The default value is false. In this case, you are required to specify an algorithm.

    Set PerformAutoML to true to have Amazon Forecast perform AutoML. This is a good option if you aren't sure which algorithm is suitable for your training data. In this case, PerformHPO must be false.

  • auto_ml_override_strategy (Optional[AutoMLOverrideStrategy], default: None ) –

    The LatencyOptimized AutoML override strategy is only available in private beta. Contact Amazon Web Services Support or your account manager to learn more about access privileges.

    Used to overide the default AutoML strategy, which is to optimize predictor accuracy. To apply an AutoML strategy that minimizes training time, use LatencyOptimized.

    This parameter is only valid for predictors trained using AutoML.

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

    Whether to perform hyperparameter optimization (HPO). HPO finds optimal hyperparameter values for your training data. The process of performing HPO is known as running a hyperparameter tuning job.

    The default value is false. In this case, Amazon Forecast uses default hyperparameter values from the chosen algorithm.

    To override the default values, set PerformHPO to true and, optionally, supply the HyperParameterTuningJobConfig object. The tuning job specifies a metric to optimize, which hyperparameters participate in tuning, and the valid range for each tunable hyperparameter. In this case, you are required to specify an algorithm and PerformAutoML must be false.

    The following algorithms support HPO:

    • DeepAR+

    • CNN-QR

  • training_parameters (Optional[TrainingParameters], default: None ) –

    The hyperparameters to override for model training. The hyperparameters that you can override are listed in the individual algorithms. For the list of supported algorithms, see aws-forecast-choosing-recipes.

  • evaluation_parameters (Optional[EvaluationParameters], default: None ) –

    Used to override the default evaluation parameters of the specified algorithm. Amazon Forecast evaluates a predictor by splitting a dataset into training data and testing data. The evaluation parameters define how to perform the split and the number of iterations.

  • hpo_config (Optional[HyperParameterTuningJobConfig], default: None ) –

    Provides hyperparameter override values for the algorithm. If you don't provide this parameter, Amazon Forecast uses default values. The individual algorithms specify which hyperparameters support hyperparameter optimization (HPO). For more information, see aws-forecast-choosing-recipes.

    If you included the HPOConfig object, you must set PerformHPO to true.

  • input_data_config (InputDataConfig) –

    Describes the dataset group that contains the data to use to train the predictor.

  • featurization_config (FeaturizationConfig) –

    The featurization configuration.

  • encryption_config (Optional[EncryptionConfig], default: None ) –

    An Key Management Service (KMS) key and the Identity and Access Management (IAM) role that Amazon Forecast can assume to access the key.

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

    The optional metadata that you apply to the predictor to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.

    The following basic restrictions apply to tags:

    • Maximum number of tags per resource - 50.

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

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

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

    • If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.

    • Tag keys and values are case sensitive.

    • Do not use aws:, AWS:, or any upper or lowercase combination of such as a prefix for keys as it is reserved for Amazon Web Services use. You cannot edit or delete tag keys with this prefix. Values can have this prefix. If a tag value has aws as its prefix but the key does not, then 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.

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

    The accuracy metric used to optimize the predictor.

Raises:

Source code in docs_src/capo_forecast/_services/async_forecast.py
async def create_predictor(
    self,
    predictor_name: "capo_forecast.types.name.Name",
    forecast_horizon: "capo_forecast.types.integer.Integer",
    input_data_config: "capo_forecast.types.input_data_config.InputDataConfig",
    featurization_config: "capo_forecast.types.featurization_config.FeaturizationConfig",
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    algorithm_arn: Optional["capo_forecast.types.arn.Arn"] = None,
    forecast_types: Optional[
        "capo_forecast.types.forecast_types.ForecastTypes"
    ] = None,
    perform_auto_ml: Optional["capo_forecast.types.boolean.Boolean"] = None,
    auto_ml_override_strategy: Optional[
        "capo_forecast.types.auto_ml_override_strategy.AutoMLOverrideStrategy"
    ] = None,
    perform_hpo: Optional["capo_forecast.types.boolean.Boolean"] = None,
    training_parameters: Optional[
        "capo_forecast.types.training_parameters.TrainingParameters"
    ] = None,
    evaluation_parameters: Optional[
        "capo_forecast.types.evaluation_parameters.EvaluationParameters"
    ] = None,
    hpo_config: Optional[
        "capo_forecast.types.hyper_parameter_tuning_job_config.HyperParameterTuningJobConfig"
    ] = None,
    encryption_config: Optional[
        "capo_forecast.types.encryption_config.EncryptionConfig"
    ] = None,
    tags: Optional["capo_forecast.types.tags.Tags"] = None,
    optimization_metric: Optional[
        "capo_forecast.types.optimization_metric.OptimizationMetric"
    ] = None,
) -> "capo_forecast.types.create_predictor_response.CreatePredictorResponse":
    """<note> <p> This operation creates a legacy predictor that does not include all the predictor functionalities provided by Amazon Forecast. To create a predictor that is compatible with all aspects of Forecast, use <a>CreateAutoPredictor</a>.</p> </note> <p>Creates an Amazon Forecast predictor.</p> <p>In the request, provide a dataset group and either specify an algorithm or let Amazon Forecast choose an algorithm for you using AutoML. If you specify an algorithm, you also can override algorithm-specific hyperparameters.</p> <p>Amazon Forecast uses the algorithm to train a predictor using the latest version of the datasets in the specified dataset group. You can then generate a forecast using the <a>CreateForecast</a> operation.</p> <p> To see the evaluation metrics, use the <a>GetAccuracyMetrics</a> operation. </p> <p>You can specify a featurization configuration to fill and aggregate the data fields in the <code>TARGET_TIME_SERIES</code> dataset to improve model training. For more information, see <a>FeaturizationConfig</a>.</p> <p>For RELATED_TIME_SERIES datasets, <code>CreatePredictor</code> verifies that the <code>DataFrequency</code> specified when the dataset was created matches the <code>ForecastFrequency</code>. TARGET_TIME_SERIES datasets don't have this restriction. Amazon Forecast also verifies the delimiter and timestamp format. For more information, see <a>howitworks-datasets-groups</a>.</p> <p>By default, predictors are trained and evaluated at the 0.1 (P10), 0.5 (P50), and 0.9 (P90) quantiles. You can choose custom forecast types to train and evaluate your predictor by setting the <code>ForecastTypes</code>. </p> <p> <b>AutoML</b> </p> <p>If you want Amazon Forecast to evaluate each algorithm and choose the one that minimizes the <code>objective function</code>, set <code>PerformAutoML</code> to <code>true</code>. The <code>objective function</code> is defined as the mean of the weighted losses over the forecast types. By default, these are the p10, p50, and p90 quantile losses. For more information, see <a>EvaluationResult</a>.</p> <p>When AutoML is enabled, the following properties are disallowed:</p> <ul> <li> <p> <code>AlgorithmArn</code> </p> </li> <li> <p> <code>HPOConfig</code> </p> </li> <li> <p> <code>PerformHPO</code> </p> </li> <li> <p> <code>TrainingParameters</code> </p> </li> </ul> <p>To get a list of all of your predictors, use the <a>ListPredictors</a> operation.</p> <note> <p>Before you can use the predictor to create a forecast, the <code>Status</code> of the predictor must be <code>ACTIVE</code>, signifying that training has completed. To get the status, use the <a>DescribePredictor</a> operation.</p> </note>

    Args:
        predictor_name: <p>A name for the predictor.</p>
        algorithm_arn: <p>The Amazon Resource Name (ARN) of the algorithm to use for model training. Required if <code>PerformAutoML</code> is not set to <code>true</code>.</p> <p class="title"> <b>Supported algorithms:</b> </p> <ul> <li> <p> <code>arn:aws:forecast:::algorithm/ARIMA</code> </p> </li> <li> <p> <code>arn:aws:forecast:::algorithm/CNN-QR</code> </p> </li> <li> <p> <code>arn:aws:forecast:::algorithm/Deep_AR_Plus</code> </p> </li> <li> <p> <code>arn:aws:forecast:::algorithm/ETS</code> </p> </li> <li> <p> <code>arn:aws:forecast:::algorithm/NPTS</code> </p> </li> <li> <p> <code>arn:aws:forecast:::algorithm/Prophet</code> </p> </li> </ul>
        forecast_horizon: <p>Specifies the number of time-steps that the model is trained to predict. The forecast horizon is also called the prediction length.</p> <p>For example, if you configure a dataset for daily data collection (using the <code>DataFrequency</code> parameter of the <a>CreateDataset</a> operation) and set the forecast horizon to 10, the model returns predictions for 10 days.</p> <p>The maximum forecast horizon is the lesser of 500 time-steps or 1/3 of the TARGET_TIME_SERIES dataset length.</p>
        forecast_types: <p>Specifies 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> <p>The default value is <code>["0.10", "0.50", "0.9"]</code>.</p>
        perform_auto_ml: <p>Whether to perform AutoML. When Amazon Forecast performs AutoML, it evaluates the algorithms it provides and chooses the best algorithm and configuration for your training dataset.</p> <p>The default value is <code>false</code>. In this case, you are required to specify an algorithm.</p> <p>Set <code>PerformAutoML</code> to <code>true</code> to have Amazon Forecast perform AutoML. This is a good option if you aren't sure which algorithm is suitable for your training data. In this case, <code>PerformHPO</code> must be false.</p>
        auto_ml_override_strategy: <note> <p> The <code>LatencyOptimized</code> AutoML override strategy is only available in private beta. Contact Amazon Web Services Support or your account manager to learn more about access privileges. </p> </note> <p>Used to overide the default AutoML strategy, which is to optimize predictor accuracy. To apply an AutoML strategy that minimizes training time, use <code>LatencyOptimized</code>.</p> <p>This parameter is only valid for predictors trained using AutoML.</p>
        perform_hpo: <p>Whether to perform hyperparameter optimization (HPO). HPO finds optimal hyperparameter values for your training data. The process of performing HPO is known as running a hyperparameter tuning job.</p> <p>The default value is <code>false</code>. In this case, Amazon Forecast uses default hyperparameter values from the chosen algorithm.</p> <p>To override the default values, set <code>PerformHPO</code> to <code>true</code> and, optionally, supply the <a>HyperParameterTuningJobConfig</a> object. The tuning job specifies a metric to optimize, which hyperparameters participate in tuning, and the valid range for each tunable hyperparameter. In this case, you are required to specify an algorithm and <code>PerformAutoML</code> must be false.</p> <p>The following algorithms support HPO:</p> <ul> <li> <p>DeepAR+</p> </li> <li> <p>CNN-QR</p> </li> </ul>
        training_parameters: <p>The hyperparameters to override for model training. The hyperparameters that you can override are listed in the individual algorithms. For the list of supported algorithms, see <a>aws-forecast-choosing-recipes</a>.</p>
        evaluation_parameters: <p>Used to override the default evaluation parameters of the specified algorithm. Amazon Forecast evaluates a predictor by splitting a dataset into training data and testing data. The evaluation parameters define how to perform the split and the number of iterations.</p>
        hpo_config: <p>Provides hyperparameter override values for the algorithm. If you don't provide this parameter, Amazon Forecast uses default values. The individual algorithms specify which hyperparameters support hyperparameter optimization (HPO). For more information, see <a>aws-forecast-choosing-recipes</a>.</p> <p>If you included the <code>HPOConfig</code> object, you must set <code>PerformHPO</code> to true.</p>
        input_data_config: <p>Describes the dataset group that contains the data to use to train the predictor.</p>
        featurization_config: <p>The featurization configuration.</p>
        encryption_config: <p>An Key Management Service (KMS) key and the Identity and Access Management (IAM) role that Amazon Forecast can assume to access the key.</p>
        tags: <p>The optional metadata that you apply to the predictor to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.</p> <p>The following basic restrictions apply to tags:</p> <ul> <li> <p>Maximum number of tags per resource - 50.</p> </li> <li> <p>For each resource, each tag key must be unique, and each tag key can have only one value.</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>If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.</p> </li> <li> <p>Tag keys and values are case sensitive.</p> </li> <li> <p>Do not use <code>aws:</code>, <code>AWS:</code>, or any upper or lowercase combination of such as a prefix for keys as it is reserved for Amazon Web Services use. You cannot edit or delete tag keys with this prefix. Values can have this prefix. If a tag value has <code>aws</code> as its prefix but the key does not, then 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.</p> </li> </ul>
        optimization_metric: <p>The accuracy metric used to optimize the predictor.</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_predictor_request.CreatePredictorRequest]",
    ) -> AsyncOperationResponse[
        "capo_forecast.types.create_predictor_response.CreatePredictorResponse"
    ]:
        import capo_forecast._operations.amazon_forecast.create_predictor

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

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

        return capo_forecast.types.create_predictor_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreatePredictor", redact_input=_redact_input),
    )
    input_: capo_forecast.types.create_predictor_request.CreatePredictorRequest = {
        "predictor_name": predictor_name,
        "forecast_horizon": forecast_horizon,
        "input_data_config": input_data_config,
        "featurization_config": featurization_config,
    }
    if algorithm_arn is not None:
        input_["algorithm_arn"] = algorithm_arn
    if forecast_types is not None:
        input_["forecast_types"] = forecast_types
    if perform_auto_ml is not None:
        input_["perform_auto_ml"] = perform_auto_ml
    if auto_ml_override_strategy is not None:
        input_["auto_ml_override_strategy"] = auto_ml_override_strategy
    if perform_hpo is not None:
        input_["perform_hpo"] = perform_hpo
    if training_parameters is not None:
        input_["training_parameters"] = training_parameters
    if evaluation_parameters is not None:
        input_["evaluation_parameters"] = evaluation_parameters
    if hpo_config is not None:
        input_["hpo_config"] = hpo_config
    if encryption_config is not None:
        input_["encryption_config"] = encryption_config
    if tags is not None:
        input_["tags"] = tags
    if optimization_metric is not None:
        input_["optimization_metric"] = optimization_metric

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