Training Predictors - Amazon Forecast

Training Predictors

A predictor is an Amazon Forecast model that is trained using your target time series, related time series, item metadata, and any additional datasets you include. You can use predictors to generate forecasts based on your time-series data.

By default, Amazon Forecast creates an AutoPredictor, where Forecast applies the optimal combination of algorithms to each time series in your datasets.

Creating a Predictor

Amazon Forecast requires the following inputs to train a predictor:

  • Dataset group – A dataset group that must include a target time series dataset. The target time series dataset includes the target attribute (item_id) and timestamp attribute, as well as any dimensions. Related time series and Item metadata is optional. For more information, see Importing Datasets.

  • Forecast frequency – The granularity of your forecasts (hourly, daily, weekly, etc).

  • Forecast horizon – The number of time steps being forecasted.

You can also set values for the following optional inputs:

  • Forecast dimensions – Dimensions are optional attributes in your target time series dataset that can be used in combination with the target value (item_id) to create separate time series.

  • Forecast types – The quantiles used to evaluate your predictor.

  • Optimization metric – The accuracy metric used to optimize your predictor.

  • Additional datasets – Built-in Amazon Forecast datasets like the Weather Index and Holidays.

You can create a predictor using the Software Development Kit (SDK) or the Amazon Forecast console.

Console

To create a predictor

  1. Sign in to the AWS Management Console and open the Amazon Forecast console at https://console.aws.amazon.com/forecast/.

  2. From Dataset groups, choose your dataset group.

  3. In the navigation pane, choose Predictors.

  4. Choose Train new predictor.

  5. Provide values for the following mandatory fields:

    • Name - a unique predictor name.

    • Forecast frequency - the granularity of your forecasts.

    • Forecast horizon - The number of time steps to forecast.

  6. Choose Start.

For information on additional datasets, see Weather Index and Holidays Featurization. To learn more about customizing forecast types and optimization metrics, see Evaluating Predictor Accuracy.

AWS CLI

To create an auto predictor with the AWS CLI, use the create-auto-predictor command. The following code creates an auto predictor that makes predictions for 14 days in the future.

Provide a name for the predictor and the Amazon Resource Name (ARN) of the dataset group that includes your training data. Optionally modify the forecast horizon and forecast frequency. Optionally add any tags for the predictor. For more information see Tagging Amazon Forecast Resources.

For information on required and optional parameters see CreateAutoPredictor.

aws forecast create-auto-predictor \ --predictor-name predictor_name \ --data-config DatasetGroupArn="arn:aws:forecast:region:account:dataset-group/datasetGroupName" \ --forecast-horizon 14 \ --forecast-frequency D \ --tags Key=key1,Value=value1 Key=key2,Value=value2

To learn more about customizing forecast types and optimization metrics, see Evaluating Predictor Accuracy The Weather Index and Holidays additional datasets are defined within the DataConfig datatype. For information on additional datasets, see Weather Index and Holidays Featurization.

Python

To create an auto predictor with the SDK for Python (Boto3), use the create_auto_predictor method. The following code creates an auto predictor that makes predictions for 14 days in the future.

Provide a name for the predictor and the Amazon Resource Name (ARN) of the dataset group that includes your training data. Optionally modify the forecast horizon and forecast frequency. Optionally add any tags for the predictor. For more information see Tagging Amazon Forecast Resources.

For information on required and optional parameters see CreateAutoPredictor.

import boto3 forecast = boto3.client('forecast') create_predictor_response = forecast.create_auto_predictor( PredictorName = 'predictor_name', ForecastHorizon = 14, ForecastFrequency = 'D', DataConfig = { "DatasetGroupArn": "arn:aws:forecast:region:account:dataset-group/datasetGroupName" }, Tags = [ { "Key": "key1", "Value": "value1" }, { "Key": "key2", "Value": "value2" } ] ) print(create_predictor_response['PredictorArn'])

To learn more about customizing forecast types and optimization metrics, see Evaluating Predictor Accuracy The Weather Index and Holidays additional datasets are defined within the DataConfig datatype. For information on additional datasets, see Weather Index and Holidays Featurization.

Upgrading to AutoPredictor

Python notebooks

For a step-by-step guide on upgrading predictors to AutoPredictor, see Upgrading a predictor to AutoPredictor.

Predictors created with AutoML or manual selection (CreatePredictor) can be upgraded to an AutoPredictor. Upgrading an existing to AutoPredictor will transfer all the relevant predictor configuration settings.

After Upgrading to AutoPredictor, the original predictor will remain active and the upgraded predictor will have a separate Predictor ARN. This enables you to compare accuracy metrics between the two predictors, and you can still generate forecasts with the original predictor.

You can upgrade a predictor using the Software Development Kit (SDK) or the Amazon Forecast console.

Console

To upgrade a predictor

  1. Sign in to the AWS Management Console and open the Amazon Forecast console at https://console.aws.amazon.com/forecast/.

  2. In the navigation pane, choose Predictors.

  3. Choose the predictor to upgrade, and choose Upgrade.

  4. Set a unique name for the upgraded predictor.

  5. Choose Upgrade to AutoPredictor.

CLI

To upgrade a predictor with the AWS CLI, use the create-auto-predictor method, but specify only the predictor name and the value of reference-predictor-arn (the ARN of the predictor you want to upgrade).

aws forecast create-auto-predictor \ --predictor-name predictor_name \ --reference-predictor-arn arn:aws:forecast:region:account:predictor/predictorName
Python

To upgrade a predictor with the SDK for Python (Boto3), use the create_auto_predictor method, but specify only the predictor name and the value of ReferencePredictorArn (the ARN of the predictor you want to upgrade).

import boto3 forecast = boto3.client('forecast') create_predictor_response = forecast.create_auto_predictor( PredictorName = 'predictor_name', ReferencePredictorArn = 'arn:aws:forecast:region:account:predictor/predictorName' ) print(create_predictor_response['PredictorArn'])

Using additional datasets

Amazon Forecast can include the Weather Index and Holidays when creating your predictor. The Weather Index incorporates meteorological information into your model and Holidays incorporates information regarding national holidays.

The Weather Index requires a ‘geolocation’ attribute in your target time series dataset and information regarding time zones for your timestamps. For more information, see Weather Index.

Holidays includes holiday information on 66 countries. For more information, see Holidays Featurization.

Working with legacy predictors

Note

To upgrade an existing predictor to AutoPredictor, see Upgrading to AutoPredictor

AutoPredictor is the default and preferred method to create a predictor with Amazon Forecast. AutoPredictor creates predictors by applying the optimal combination of algorithms for each time series in your dataset.

Predictors created with AutoPredictor are generally more accurate than predictors created with AutoML or manual selection. The Forecast Explainability and predictor retraining features are only available for predictors created with AutoPredictor.

Amazon Forecast can also create legacy predictors in the following ways:

  1. AutoML - Forecast finds the best-performing algorithm and applies it to your entire dataset.

  2. Manual selection - Manually choose a single algorithm that is applied to your entire dataset.

You can create a legacy predictor using the Software Development Kit (SDK) or the Amazon Forecast console.

Console

To use AutoML

  1. Sign in to the AWS Management Console and open the Amazon Forecast console at https://console.aws.amazon.com/forecast/.

  2. From Dataset groups, choose your dataset group.

  3. In the navigation pane, choose Predictors.

  4. Choose Train new predictor.

  5. In the Predictor configuration section, unselect Enable AutoPredictor.

  6. Expand the Algorithm selection drop-down and choose Automatic (AutoML).

SDK

To use AutoML

Using the CreatePredictor operation, set the value of PerformAutoML to "true".

{ ... "PerformAutoML": "true", }

If you use AutoML, you cannot set a value for the following CreatePredictor parameters: AlgorithmArn, HPOConfig, TrainingParameters.