This workshop demonstrates how to use AWS services to implement time series forecasting. It covers the following examples and AWS services:
- Amazon SageMaker Canvas
- Amazon SageMaker Autopilot API
- Amazon SageMaker DeepAR
- Chronos
- AutoGluon
Additional notebooks cover forecasting with GluonTS, a custom algorithm on SageMaker, and Amazon QuickSight.
The workshop is available in AWS workshop catalog. You can run this workshop on an AWS-led event or in your own AWS account.
To use this workshop, you need an Amazon SageMaker domain. All workshop content is in Jupyter notebooks running on Amazon SageMaker. To get started, follow the instructions in the Getting started section. To clean up resources, follow the instructions in the Clean-up section. You can execute the notebooks in any order, and you don't need to switch between the notebooks and the workshop web page.
Ignore this section if you're using an AWS-provided account as a part of an AWS-led workshop.
In order to be able to run notebooks and complete workshop labs you need access to the following resources in your AWS account. You can check quotas for all following resources in AWS console in Service Quotas console.
Studio JupyterLab app
Minimal required instance type is ml.m5.2xlarge
. We recommend to use ml.m5.4xlarge
as an instance to run all notebooks. If you have access to GPU-instances like ml.g5.4xlarge
or ml.g6.4xlarge
, use these instance to run the notebooks.
To experiment with the full dataset with 370 time series in the lab 5 AutoGluon you need a GPU instance for the notebook - ml.g5.4xlarge
/ml.g6.4xlarge
or ml.g5.8xlarge
/ml.g6.8xlarge
.
- Check quota for
ml.m5.2xlarge
- Check quota for
ml.m5.4xlarge
- Check quota for
ml.g5.4xlarge
- Check quota for
ml.g6.4xlarge
- Check quota for
ml.g5.8xlarge
- Check quota for
ml.g6.8xlarge
Number of concurrent AutoML Jobs
To follow the optimal flow of the workshop, you need to run at least three AutoML jobs in parallel. We recommend to have a quota set to six or more concurrent jobs.
- Check quota for maximum number of concurrent AutoML Jobs
Training jobs
To run a training job for DeepAR algorithm you need a ml.c5.4xlarge
compute instance
- Check quota for
ml.c5.4xlarge
SageMaker real-time inference endpoints
DeepAR, Chronos, and AutoGluon notebooks deploy SageMaker real-time inference endpoints to test models. You need access to the following compute instances for endpoint use:
- Minimal for Autopilot and DeepAR endpoints: check
ml.m5.xlarge
- Recommended for Autopilot and DeepAR endpoints: check
ml.m5.4xlarge
- Minimal for Chronos Small endpoint: check
ml.g5.xlarge
- Optional for Chronos Base: check
ml.g5.2xlarge
- Optional for Chronos Large: check
ml.g5.4xlarge
The notebooks from Lab 1 to Lab 5 are self-sufficient. You can run them in any order. If you're unfamiliar with time series forecasting, we recommend starting with the Lab 1 notebook and continuing from there. Alternatively, you can run only the notebooks that interest you, such as lab4_chronos
or lab5_autogluon
.
The model training in Labs 1, 2, and 3 takes 15-40 minutes, depending on the algorithm. You don't need to wait for the training to complete before moving on to the next notebook. You can come back to the previous notebook once the training is done.
Executing all five notebooks will take 2-3 hours. If you're new to time series forecasting, Jupyter notebooks, or Python, it may take longer.
The notebooks in this workshop create cost-generating resources in your account. Make sure you always delete created SageMaker inference endpoints, log out of Canvas, and stop JupyterLab spaces if you don't use them.
If running all notebooks with all sections, including optional sections and training three models using Standard builds in Canvas, the estimated cost is approximately 90-100 USD.
Please note that your actual costs may vary depending on the duration of the workshop, the number of inference endpoints created, and the time the endpoints remain in service.
To optimize costs, follow these recommendations:
- Run only Quick builds in Canvas to minimize costs. Note that in this case you cannot download model performance JSON files
- Use only a sample from the full dataset to train models and run all experiments. Each notebook contains code to create a small dataset with a sample from the time series
- Promptly delete SageMaker inference endpoints after use
- Use
ml.m5.xlarge
instance for JupyterLab app to balance performance and cost - Limit Chronos experiments to one endpoint and a sample of the time series in the notebook
lab4_chronos
If you'd lke to create a new domain, you have two options:
- Use the provided AWS CloudFormation template that creates a SageMaker domain, a user profile, and adds the IAM roles required for executing the provided notebooks - this is the recommended approach
- Follow the onboarding instructions in the Developer Guide and create a new domain and a user profile via AWS Console
All examples and notebooks in this workshop using the same real-world dataset. It makes possible to compare performance and model metrics across different approaches.
You use the electricity dataset from the repository of the University of California, Irvine:
Trindade, Artur. (2015). ElectricityLoadDiagrams20112014. UCI Machine Learning Repository. https://doi.org/10.24432/C58C86.
Open the lab 1 notebook and follow the instructions.
Additional SageMaker Canvas links:
- Time Series Forecasts in Amazon SageMaker Canvas
- Canvas Workshop - time series forecast lab
- Time-Series Forecasting Using Amazon SageMaker Canvas
Open the lab 2 notebook and follow the instructions.
Note: previous Autopilot UX in Studio Classic merged with Canvas as of re:Invent 2023. All AutoML functionality is moved to Canvas as of now.
Additional SageMaker Autopilot API links:
- Amazon SageMaker Autopilot
- Time series forecasting algorithms in SageMaker
- Example notebook Time series Forecasting with Amazon SageMaker Autopilot
- Lab 2 - Demand Forecasting with SageMaker Autopilot API
- Time series forecasting with Amazon SageMaker AutoML
Open the lab 3 notebook and follow the instructions.
Additional DeepAR links:
- Use the SageMaker DeepAR forecasting algorithm
- Deep AR Forecasting
- Example notebook
- Deep Demand Forecasting with Amazon SageMaker notebook
- DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks
- Predictive Analytics with Time-series Machine Learning on Amazon Timestream
- Bike-Share Demand Forecasting 2b: SageMaker DeepAR Algorithm
Open the lab 4 notebook and follow the instructions.
Links to more Chronos content:
- Chronos models on Huggingface
- Chronos GitHub
- Lot of Chronos-related content on Chronos GitHub
- Chronos: Learning the Language of Time Series
- Adapting language model architectures for time series forecasting
- Evaluating Chronos models
- Chronos-related content on Chronos GitHub
Open the lab 5 notebook and follow the instructions.
Links to AutoGluon content:
- AutoGluon time series
- AutoGluon Chronos
- AutoGluon Cloud
- AutoGluon Assistant
The additional notebooks in the folder notebooks/additional
cover more approaches you can use for time series forecasting. These notebooks demonstrate:
- GluonTS
- Custom algorithms on SageMaker
- Amazon QuickSight forecast
Navigate to the additional
folder inside the notebooks
folder. Open the lab 1A notebook and follow the instructions.
The notebook additional\lab1a_gluonts
also contains an end-to-end example of productization of a time series forecasting workflow. The lab demonstrates how to create a reproducible SageMaker pipeline with data processing, model training, model evaluation, model registration in the model registry, and model deployment to a SageMaker endpoint. The notebook uses GluonTS implementation of Temporal Fusion Transformer forecast and SageMaker Python SDK PyTorch framework together with SageMaker built-in Deep Learning Containers (DLC).
Links to GluonTS content:
- GluonTS: Probabilistic and Neural Time Series Modeling in Python
- Creating neural time series models with Gluon Time Series
- Deep demand forecast with Amazon SageMaker
This example is under development.
Refer to the following resources to see how you can run custom algorithms on SageMaker:
- Robust time series forecasting with MLOps on Amazon SageMaker
- Deep demand forecast with Amazon SageMaker
- Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting (AAAI'21 Best Paper)
- GluonTS - Probabilistic Time Series Modeling in Python
Amazon QuickSight has ML features to give you hidden insights and trends in your data. One of these ML features is ML-powered forecast. The built-in ML forecast uses Random Cut Forest (RCF) algorithm to detect seasonality, trends, exclude outliers, and impute missing values. For more details on how QuickSight uses RCF to generate forecasts, see the developer guide.
You can customize multiple settings on the Forecast properties pane, such as number of forecast periods, prediction interval, seasonality, and forecast boundaries.
For more details refer to the Developer Guide Forecasting and creating what-if scenarios with Amazon QuickSight.
Besides a graphical forecasting, you can also add a forecast as a narrative in an insight widget. To learn more, see Creating autonarratives with Amazon QuickSight.
Additional resources for Amazon QuickSight forecasting:
Open the lab 6 notebook and follow the instructions.
Additional resources about time series forecast accuracy evaluation
- Evaluating Predictor Accuracy
- Evaluating Chronos models
- Forecasting time series - evaluation metrics
To avoid unnecessary costs, you must remove all project-provisioned and generated resources from your AWS account.
You must complete this section before deleting the SageMaker domain or the CloudFormation stack.
Complete the following activities to shut down your Amazon SageMaker resources:
- Log out of Canvas
- Make sure to delete all endpoints created by this workshop including Canvas asynchronous endpoints
- Stop running applications and spaces in Studio > follow the instructions in the section Use the Studio UI to delete your domain applications
You don't need to complete this section if you run an AWS-instructor led workshop in an AWS-provisioned account.
If you used the AWS Console to provision a Studio domain for this workshop, and don't need the domain, you can delete the domain by following the instructions in the Developer Guide.
If you provisioned a Studio domain with the provided CloudFormation template, you can delete the CloudFormation stack in the AWS console.
If you provisioned a new VPC for the domain, go to the VPC console and delete the provisioned VPC.
- References for machine learning and RCF
- Chronos forecasting GitHub repository
- Adapting language model architectures for time series forecasting
- Chronos: Learning the Language of Time Series
- AutoGluon
- AutoGluon Time series forecasting
- GluonTS - Probabilistic Time Series Modeling in Python
- Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting
- Time Series Analysis on AWS: Learn how to build forecasting models and detect anomalies in your time series data
- Time Series Forecasting Principles with Amazon Forecast
- Large Language Models Are Zero-Shot Time Series Forecasters
- An Evaluation of Standard Statistical Models and LLMs on Time Series Forecasting
- Forecasting: Principles and Practice
- A simple combination of univariate models
- Robust time series forecasting with MLOps on Amazon SageMaker
- Deep demand forecasting with Amazon SageMaker
- Capture public health insights more quickly with no-code machine learning using Amazon SageMaker Canvas
- Speed up your time series forecasting by up to 50 percent with Amazon SageMaker Canvas UI and AutoML APIs
- Sagemaker Automated Model Tuning
- Time series forecasting with Amazon SageMaker AutoML
- Time series forecasting with AWS services workshop
- Time series Forecasting with Amazon SageMaker Autopilot
- Deep Demand Forecasting with Amazon SageMaker notebook
- Timeseries Forecasting on AWS
- Inventory Forecasting using Amazon SageMaker
- Tutorial at IJCAI 2021 (with videos)
Link: https://github.com/aws-samples/modern-time-series-forecasting-on-aws
Short link: https://bit.ly/47hnKH6
Link: https://catalog.workshops.aws/modern-time-series-forecasting-on-aws/en-US
Short link: https://bit.ly/4dBQ0G8
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0