GluonTS: Probabilistic Time Series Forecasting for Python Developers

Jul 5, 2025

Introduction

Predicting future trends from historical data is a cornerstone of modern business intelligence, yet many developers struggle with the gap between simple linear regressions and complex deep learning architectures. GluonTS is a specialized Python library for probabilistic time series modeling that bridges this gap, providing a unified interface for both classical statistical models and state-of-the-art neural networks. With a strong foundation in the AWS ecosystem and extensive support for PyTorch and MXNet, GluonTS allows data scientists to move from a simple baseline to a production-ready deep learning forecaster without rewriting their entire data pipeline.

What Is GluonTS?

GluonTS is a Python package for probabilistic time series modeling, focusing on deep learning based models, based on PyTorch and MXNet. It is maintained by AWS Labs and licensed under the Apache License 2.0. The library is designed to handle the unique challenges of time series data, such as seasonality, trend, and the need for probabilistic forecasts (predicting a distribution of possible future values rather than a single point estimate).

Unlike general-purpose machine learning libraries, GluonTS provides specialized abstractions like Estimator and Predictor. An Estimator is used to train a global model across multiple time series, while a Predictor is the resulting model that can generate forecasts for specific series. This architecture allows for efficient scaling across thousands of related time series, a common requirement in retail, logistics, and energy forecasting.

Why GluonTS Matters

Traditional time series tools often force a choice between “local” models (like ARIMA), which are fitted to a single series and fail to capture cross-series patterns, and “global” deep learning models, which are difficult to implement from scratch. GluonTS matters because it provides a single toolkit where both can coexist. This allows developers to establish a baseline using a simple local model and then incrementally upgrade to a global neural network as the dataset grows.

The shift toward probabilistic forecasting is another key differentiator. Instead of predicting that a product will sell exactly 100 units, GluonTS can predict a 90% probability that sales will fall between 80 and 120 units. This uncertainty quantification is critical for risk management, inventory planning, and avoiding stock-outs in high-stakes production environments.

Furthermore, its deep integration with Amazon SageMaker makes it the industry standard for teams deploying time series models at scale in the cloud. By providing pre-built containers and optimized training scripts, it removes the DevOps friction typically associated with deploying PyTorch or MXNet models for forecasting.

Key Features

  • Probabilistic Forecasting: Instead of point estimates, GluonTS generates sample paths or quantiles, allowing users to visualize and quantify the uncertainty of future predictions.
  • Global Model Support: The library can train a single model (like DeepAR) across thousands of different time series, learning shared patterns that improve the accuracy of individual forecasts.
  • Multi-Backend Flexibility: It supports both PyTorch and MXNet, giving developers the choice of the most suitable deep learning framework for their existing infrastructure.
  • Comprehensive Model Zoo: Includes implementations of state-of-the-art models such as DeepAR, N-BEATS, Temporal Fusion Transformer (TFT), and WaveNet, alongside classical models like ARIMA and ETS.
  • Unified Data Pipeline: Provides specialized PandasDataset and Dataset objects that handle the complexities of time series splitting, frequency management, and feature engineering.
  • Zero-Shot Forecasting with Chronos: Through the Chronos suite, GluonTS now supports pretrained models that can generate accurate predictions for new time series without any additional training.
  • Integrated Evaluation Metrics: Built-in tools for calculating CRPS (Continuous Ranked Probability Score) and other probabilistic metrics to accurately measure model performance.
  • SageMaker Integration: Optimized for seamless deployment on Amazon SageMaker, facilitating the transition from local experimentation to cloud-scale production.

How GluonTS Compares

When choosing a forecasting library, developers typically compare GluonTS against tools like Facebook Prophet or the Darts library. While Prophet is excellent for a single series with strong seasonality, it lacks the ability to learn across multiple series. Darts is a high-level wrapper that provides a great API, but GluonTS offers deeper, more specialized probabilistic tools and tighter integration with AWS.

Feature GluonTS Facebook Prophet Darts
Model Type Global & Local Local Only Global & Local
Probabilistic Output Native/Advanced Basic Supported
Deep Learning Backends PyTorch, MXNet Stan PyTorch, etc.
Cloud Integration AWS SageMaker General General
Learning Curve Moderate Low Low to Moderate

The primary tradeoff is complexity. Prophet is significantly easier to set up for a single-series forecast. However, for enterprise-scale forecasting where you have 10,000+ time series and need to learn shared patterns, GluonTS is the superior choice. It provides the mathematical rigor required for probabilistic forecasting that simple additive models cannot match.

Getting Started: Installation

GluonTS uses a minimal dependency model to keep the installation lightweight. You must install the core library and then add “extras” based on the the deep learning backend you intend to use.

Using pip

For most users, the easiest way to install GluonTS with PyTorch support is via pip:

pip install "gluonts[torch]"

If you prefer to use MXNet models, use the following command:

pip install "gluonts[mxnet]"

Using uv

For faster environment management, the project recommends using uv:

uv pip install "gluonts[torch]"

Installing from Source

If you are contributing to the project or need the latest features from the development branch, you can clone the repository and install it in development mode:

git clone https://github.com/awslabs/gluonts.git
cd gluonts
uv sync --all-extras

Prerequisites: GluonTS requires Python 3.10 to 3.14. Ensure your environment is configured with the correct Python version before installation.

How to Use GluonTS

The basic workflow in GluonTS follows a consistent pattern: data preparation, estimator initialization, training, and prediction. The library uses a Dataset object to wrap time series data, which is typically converted from a Pandas DataFrame.

First, you define a PandasDataset, which specifies the target values and the frequency of the observations (e.g., “H” for hourly, “D” for daily). Then, you initialize an Estimator (such as DeepAREstimator), specifying the prediction_length—the number of steps into the future you want to predict.

Finally, you call the .train() method on the estimator. This returns a Predictor object, which you can then use to generate probabilistic forecasts for your test data. This separation of training and prediction is what allows GluonTS to scale to massive datasets in an offline training phase and provide fast, online predictions.

Code Examples

The following example demonstrates how to train a DeepAR model on the classic AirPassengers dataset to predict future passenger numbers.

import pandas as pd
import matplotlib.pyplot as plt
from gluonts.dataset.pandas import PandasDataset
from gluonts.torch import DeepAREstimator

# Load data
df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv", index_col=0, parse_dates=True)

# Create a dataset
# target: the values we want to predict
# freq: the frequency of the time series
dataset = PandasDataset(df, target="passenger_count", freq="M")

# Initialize the estimator
estimator = DeepAREstimator(
    freq="M", 
    prediction_length=12, 
    context_length=24
)

# Train the model to get a predictor
predictor = estimator.train(dataset)

# Make predictions
forecasts = predictor.predict(dataset)

# Plot the results
plt.plot(df.index, df["passenger_count"])
plt.plot(forecasts.mean, label="mean forecast")
plt.show()

For more complex scenarios, you can use make_evaluation_predictions to automate the process of backtesting and calculating accuracy metrics like the Continuous Ranked Probability Score (CRPS).

Real-World Use Cases

GluonTS is particularly effective in scenarios where you have many related time series and need to quantify uncertainty.

  • Retail Demand Forecasting: A retailer with 10,000+ SKUs across 100 stores can use a global model to learn shared seasonality and trends across all products, improving forecasts for new products with little historical data (cold-start problem).
  • Energy Grid Management: Utility companies can predict hourly electricity consumption for thousands of customers. By using probabilistic forecasts, they can plan for peak load with a 95% confidence interval, reducing the risk of blackouts.
  • Cloud Infrastructure Scaling: DevOps teams can forecast CPU and memory usage for server clusters. Predicting the probability of a spike in traffic allows for proactive auto-scaling of resources to maintain application performance.
  • Financial Planning: Analysts can forecast revenue streams with confidence intervals, allowing for more realistic budget planning and the ability to perform “worst-case” and “best-case” scenario analysis.

Contributing to GluonTS

GluonTS is an open-source project maintained by AWS Labs. Contributions are welcome and typically follow the standard GitHub flow. Developers can report bugs via the GitHub Issues tracker or suggest new features through the official discussions. If you are looking to contribute code, it is recommended to start by looking for “good first issues” to familiarize yourself with the laibary’s architecture.

The project adheres to a Code of Conduct to ensure a professional and community-driven development environment. To get started with contributing, developers should clone the repository and set up the development environment using uv sync --all-extras as detailed in the installation section.

Community and Support

The primary hub for GluonTS support is the GitHub repository, where developers can use GitHub Discussions for architectural questions and the Issues tracker for bug reports. The project also provides extensive documentation at ts.gluon.ai, which includes a comprehensive API reference and a set of tutorials for getting started.

The community is active, with over 100 unique contributors over the project’s lifetime, contributing to a wide range of models and utilities. Because it is an AWS-backed project, it is widely used in production environments across the same ecosystem, making it easier to find community-driven examples and AWS-specific implementation guides.

Conclusion

GluonTS is the right choice for developers who need to move beyond point-estimate forecasting and embrace probabilistic modeling at scale. While it has a steeper learning curve than simple tools like Prophet, the ability to learn across multiple time series and the integrate with AWS SageMaker makes it a powerful asset for enterprise-grade predictive analytics.

If you are managing a small number of series with clear seasonality, a local model may suffice. However, if you are building a production system that requires uncertainty quantification and scalability, GluonTS is the industry standard. Star the repo, try the quickstart, and join the community to start building more resilient forecasts.

What is GluonTS and what problem does it solve?

GluonTS is a Python library for probabilistic time series modeling that solves the problem of scaling forecasting models across thousands of related time series. It allows developers to use both classical statistical models and deep learning models to generate forecasts that include uncertainty quantification (confidence intervals) rather than just a single point estimate.

How do I install GluonTS?

The easiest way to install GluonTS is via pip using the command pip install "gluonts[torch]" for PyTorch support or pip install "gluonts[mxnet]" for MXNet support. For those using the uv package manager, the same extras syntax is used: uv pip install "gluonts[torch]".

How does GluonTS compare to Facebook Prophet?

While Facebook Prophet is designed for local models that are fitted to a single time series, GluonTS is designed for global models that can learn shared patterns across multiple series. This makes GluonTS significantly more scalable for enterprise applications where thousands of forecasts must be generated simultaneously.

Can I use GluonTS for anomaly detection?

GluonTS provide a toolkit for both forecasting and anomaly detection. By generating probabilistic forecasts, the library can identify observations that fall outside of the predicted confidence intervals, which can be used to trigger alerts for unusual system behavior.

What is the difference between an Estimator and a Predictor in GluonTS?

An Estimator is the class used to train a global model on a training dataset to learn general patterns. A Predictor is the resulting model object that is produced by the estimator’s .train() method and is used to make actual predictions for specific time series.

Does GluonTS support PyTorch and MXNet?

Yes, GluonTS supports both PyTorch and MXNet as deep learning backends. This allows developers to integrate the library into their existing ML pipelines without being forced to use a specific framework.

Can I use GluonTS for multivariate time series forecasting?

GluonTS supports multivariate forecasting through models like DeepVAR, which can predict multiple target variables simultaneously by learning their interdependencies.

What is the license of GluonTS?

GluonTS is licensed under the Apache License 2.0, making it open-source and free for commercial use, modification, and distribution.