GluonTS is an open-source Python library for probabilistic time series modeling, developed by Amazon researchers and first released in 2019. In time series & forecasting, it provides ready-made deep-learning forecasters, classical baselines, dataset utilities and evaluation tools under one consistent interface, with an emphasis on predicting full probability distributions rather than single point values.
The name comes from the Gluon API of Apache MXNet, the framework on which the library was originally built. Later versions added a PyTorch backend, which has become the main path for new models as MXNet development ended. GluonTS also serves as a foundation for higher-level tools, including the time series module of AutoGluon.
How GluonTS structures a forecasting workflow
GluonTS structures every forecasting task as a pipeline of datasets, transformations, estimators, predictors and evaluators. This separation lets a practitioner swap one model for another without rewriting data loading or evaluation code.
An estimator holds the model definition and training settings, such as the prediction length, context length and number of epochs. Calling its train method on a dataset returns a predictor, a trained object that produces forecasts for new series and can be serialized for deployment. The table below lists the core abstractions.
| Component | Role | Example |
|---|---|---|
| Dataset | Iterable of series entries with start time and target | Electricity demand per household |
| Transformation | Feature creation, windowing, instance sampling | Adding lag and calendar features |
| Estimator | Untrained model with hyperparameters | DeepAR estimator, 24-step horizon |
| Predictor | Trained model that outputs forecasts | Serialized model in a batch job |
| Forecast | Sample paths, quantiles or distributions | Sample forecast with 100 paths |
| Evaluator | Computes accuracy metrics on backtests | MASE and weighted quantile loss |
Data format and feature handling
GluonTS represents each time series as a dictionary-like entry with a start timestamp, a frequency and a target array. Optional fields carry static categorical features, such as a store or product identifier, and dynamic real-valued features, such as prices or holiday flags, that are known over the forecast horizon.
Transformations then build the model inputs automatically. They add lag features, time features derived from the calendar, an age feature counting steps since the series began, and an observed-values indicator that handles missing data without imputation. Training windows are sampled at random positions, which lets one global forecasting model learn from thousands of series at once.
Models available in GluonTS
GluonTS includes a broad catalog of forecasting models, from simple baselines to sequence-to-sequence networks. Availability differs between the PyTorch and MXNet implementations, and some models are maintained only in one backend.
| Model family | Approach | Typical strength |
|---|---|---|
| DeepAR | Autoregressive recurrent network with a likelihood head | Many related series, probabilistic output |
| Temporal Fusion Transformer | Attention with variable selection | Rich covariates and interpretability |
| Simple feed-forward | Multilayer perceptron over a context window | Fast, strong baseline |
| Quantile CNN and RNN models | Direct multi-horizon quantile regression | Demand planning at fixed quantiles |
| PatchTST and other transformers | Patch-based or encoder-decoder attention | Long context windows |
| Seasonal naive and NPTS | Non-learned baselines | Sanity checks and benchmarks |
Most neural models end in a distribution output layer, for example a Student t, negative binomial or Gaussian distribution. The network predicts the distribution parameters at each step, and training maximizes the likelihood of the observed values. A negative binomial output suits count data such as unit sales, while a Student t output is more robust to outliers in continuous data.
Evaluation and backtesting
GluonTS evaluates models by backtesting on held-out final windows of each series and computing both point and probabilistic metrics. A helper function generates forecasts and matching ground truth, and the evaluator aggregates metrics across all series.
Probabilistic metrics matter because a model can have a good median forecast but poorly calibrated uncertainty. Weighted quantile loss, closely related to the pinball loss, rewards forecasts whose quantiles cover the right share of outcomes. The library also ships loaders for benchmark datasets such as M4, electricity and traffic, which supports fair comparison with published results.
| Metric | Type | What it measures |
|---|---|---|
| MASE | Point, scaled | Error relative to a seasonal naive forecast |
| sMAPE | Point, percentage | Symmetric relative error |
| Weighted quantile loss | Probabilistic | Accuracy at chosen quantiles |
| Mean weighted quantile loss | Probabilistic | Approximation of CRPS across quantiles |
| Coverage | Calibration | Share of observations below each quantile |
GluonTS compared with other forecasting libraries
GluonTS is best understood as a research-grade toolkit for probabilistic deep forecasting, whereas other libraries emphasize statistical models, general machine learning pipelines or automation.
| Tool | Primary focus | When to choose it |
|---|---|---|
| GluonTS | Probabilistic deep-learning models | Many related series, uncertainty needed |
| Prophet | Additive trend and seasonality model | Single business series with holidays |
| sktime | Unified interface for many time series tasks | Classical models and classification |
| AutoGluon-TimeSeries | Automated ensembles built partly on GluonTS | Strong results with little tuning |
| Chronos and other foundation models | Pretrained zero-shot forecasters | No training data per task |
Limitations and practical advice
The main practical limitation of GluonTS is framework churn. Code written for the MXNet backend often needs changes for the PyTorch backend, and some older tutorials no longer run on current versions. Teams should pin library versions in production and check which backend a model uses.
- Deep models need many series. For one short series, ETS or ARIMA models often match or beat neural forecasters.
- Frequency strings must be consistent. A mismatch between data frequency and model settings silently breaks lag and calendar features.
- Context length matters. Too short a context misses seasonality; too long slows training without gains.
- Always compare with baselines. A seasonal naive forecast reveals whether a complex model adds real value.
A non-technical view
GluonTS is a free toolbox for programmers who need to predict numbers over time. Examples include tomorrow’s electricity use or next month’s sales. It contains many ready-made prediction methods in one place.
Its special strength is honesty about uncertainty. Instead of one guess, it gives a range of likely outcomes, such as a low, a typical and a high value. Planners can then decide how much risk they accept, much like a weather forecast that gives a chance of rain instead of a promise.
A concrete example
A grocery chain with 300 stores needs daily sales forecasts for about 5,000 products per store, two weeks ahead. Many products sell only a few units a day, so the data contains frequent zeros and sudden spikes during promotions.
The data science team uses GluonTS to train one DeepAR model with a negative binomial output on all store and product combinations. Store and product identifiers enter as static features, and planned promotions and holidays enter as dynamic features. The team backtests on the last eight weeks of history and compares the model with a seasonal naive baseline.
The model achieves a lower weighted quantile loss than the baseline, and its 90th percentile forecasts become the basis for safety stock. Store managers order to that level for perishable goods with high stockout costs, which reduces empty shelves while keeping waste within budget.