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
PerformAutoMLis not set totrue.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
DataFrequencyparameter 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
PerformAutoMLtotrueto 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,PerformHPOmust be false. -
auto_ml_override_strategy(Optional[AutoMLOverrideStrategy], default:None) –The
LatencyOptimizedAutoML 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
PerformHPOtotrueand, 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 andPerformAutoMLmust 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
HPOConfigobject, you must setPerformHPOto 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 hasawsas 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 ofawsdo not count against your tags per resource limit.
-
-
optimization_metric(Optional[OptimizationMetric], default:None) –The accuracy metric used to optimize the predictor.
Raises:
-
InvalidInputException–We can't process the request because it includes an invalid value or a value that exceeds the valid range.
-
LimitExceededException–The limit on the number of resources per account has been exceeded.
-
ResourceAlreadyExistsException–There is already a resource with this name. Try again with a different name.
-
ResourceInUseException–The specified resource is in use.
-
ResourceNotFoundException–We can't find a resource with that Amazon Resource Name (ARN). Check the ARN and try again.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_forecast/_services/async_forecast.py
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 | |