Forecast
๐ What is Amazon Forecast?¶
Amazon Forecast is a fully managed service that uses machine learning to deliver highly accurate time series forecasts. It is based on the same technology Amazon.com uses for predicting demand, sales, and inventory.
โ No ML experience required. Just bring historical time-series data and related metadata (like item ID, category, location).
๐ฆ Use Cases¶
| Domain | Example Forecasting Use Case |
|---|---|
| Retail | Demand forecasting, product sales |
| Supply Chain | Inventory planning, stockouts |
| Energy | Power demand prediction |
| Finance | Revenue projection, cost estimation |
| Healthcare | Bed availability, patient intake |
| Workforce | Staff scheduling, call center volume |
๐ Forecast Capabilities¶
| Feature | Description |
|---|---|
| AutoML | Selects the best algorithm automatically |
| Domain-specific models | Includes CNN-QR, DeepAR+, Prophet, ARIMA |
| Related time series | Incorporate external data like weather, price, holiday |
| Item metadata support | Use product category, brand, etc. to improve accuracy |
| Probabilistic forecasts | Predict confidence intervals (P10, P50, P90) |
| Retrainable & reusable models | Models can be retrained and reused |
| Export to S3 or inference | Run batch forecasts or export CSV to S3 |
๐ Required Input Datasets¶
| Dataset Name | Required | Description |
|---|---|---|
| Target Time Series | โ Yes | Historical demand per item per timestamp |
| Related Time Series | Optional | Weather, promotions, price, etc. |
| Item Metadata | Optional | Product category, brand, warehouse, etc. |
โ Must include:
-
item_id -
timestamp -
target_value
๐ง Forecasting Workflow¶
-
Prepare Data โ Upload CSVs to S3
-
Create Dataset Group
-
Create Predictor (train model)
-
Create Forecast
-
Query or Export Forecast Results
๐งช Sample Python (Boto3) Code¶
Step 1: Create Dataset Group¶
import boto3
forecast = boto3.client('forecast')
forecast.create_dataset_group(
DatasetGroupName='sales-forecast-group',
Domain='RETAIL',
DatasetArns=[
'arn:aws:forecast:...:dataset/target_time_series'
]
)
Step 2: Train Predictor¶
forecast.create_predictor(
PredictorName='sales-predictor',
ForecastHorizon=30,
PerformAutoML=True,
InputDataConfig={
'DatasetGroupArn': 'arn:aws:forecast:...:dataset-group/sales-forecast-group'
},
FeaturizationConfig={
'ForecastFrequency': 'D',
'Featurizations': [{'AttributeName': 'target_value', 'FeaturizationPipeline': []}]
}
)
Step 3: Generate Forecast¶
forecast.create_forecast(
ForecastName='sales-forecast',
PredictorArn='arn:aws:forecast:...:predictor/sales-predictor'
)
Step 4: Query Forecast Results¶
query = boto3.client('forecastquery')
response = query.query_forecast(
ForecastArn='arn:aws:forecast:...:forecast/sales-forecast',
StartDate='2025-07-01T00:00:00',
EndDate='2025-07-31T00:00:00',
Filters={"item_id": "item-001"}
)
print(response['Forecast']['Predictions'])
๐งพ Output Example¶
{
"Predictions": {
"p10": [{"Timestamp": "2025-07-01", "Value": "125.5"}, ...],
"p50": [{"Timestamp": "2025-07-01", "Value": "140.7"}, ...],
"p90": [{"Timestamp": "2025-07-01", "Value": "160.2"}, ...]
}
}
๐ฐ Pricing (2024)¶
| Component | Price |
|---|---|
| Training (AutoML) | $0.60 per training hour |
| Inference | $0.00075 per forecasted data point (per item, per timestamp) |
| S3 Storage | Standard S3 pricing |
| Free Tier | 10,000 forecast units/month for first 2 months |
๐ง Forecast Unit = 1 item ร 1 timestamp.
๐ก๏ธ Security¶
| Feature | Support |
|---|---|
| IAM role for access | โ Required for S3 + Forecast |
| KMS Encryption | โ Optional for input/output |
| VPC Support | โ Not supported |
| CloudTrail | โ Yes for API logging |
๐งฑ Terraform Example¶
Amazon Forecast has limited Terraform support. Here's how to create a dataset:
resource "aws_forecast_dataset" "target_dataset" {
dataset_name = "my-forecast-dataset"
domain = "RETAIL"
dataset_type = "TARGET_TIME_SERIES"
data_frequency = "D"
schema = jsonencode({
Attributes = [
{ AttributeName = "item_id", AttributeType = "string" },
{ AttributeName = "timestamp", AttributeType = "timestamp" },
{ AttributeName = "target_value", AttributeType = "float" },
]
})
}
๐ง Model Types Used by Forecast¶
-
DeepAR+ โ probabilistic RNN (great for sparse and intermittent demand)
-
CNN-QR โ convolutional quantile regression
-
ARIMA โ traditional time series
-
Prophet โ from Facebook, seasonal forecasting
-
ETS โ exponential smoothing
Forecast automatically selects the best model using AutoML (unless overridden).
โ TL;DR Summary¶
| Feature | Amazon Forecast |
|---|---|
| Forecast type | Time series (quantitative) |
| Manual or AutoML | โ Both supported |
| Forecast horizon | Up to 500 days |
| Confidence intervals | โ P10, P50, P90 |
| Input format | CSV (uploaded to S3) |
| Inference options | Batch queries via API or S3 export |
| Free Tier | โ 10K forecasts/month (2 months) |
| Terraform support | โ Partial (dataset/dataset group only) |
| Common integrations | S3, Lambda, Athena, Step Functions |