GluonTS

On this page 8

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.

ComponentRoleExample
DatasetIterable of series entries with start time and targetElectricity demand per household
TransformationFeature creation, windowing, instance samplingAdding lag and calendar features
EstimatorUntrained model with hyperparametersDeepAR estimator, 24-step horizon
PredictorTrained model that outputs forecastsSerialized model in a batch job
ForecastSample paths, quantiles or distributionsSample forecast with 100 paths
EvaluatorComputes accuracy metrics on backtestsMASE and weighted quantile loss
Core abstractions in GluonTS

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 familyApproachTypical strength
DeepARAutoregressive recurrent network with a likelihood headMany related series, probabilistic output
Temporal Fusion TransformerAttention with variable selectionRich covariates and interpretability
Simple feed-forwardMultilayer perceptron over a context windowFast, strong baseline
Quantile CNN and RNN modelsDirect multi-horizon quantile regressionDemand planning at fixed quantiles
PatchTST and other transformersPatch-based or encoder-decoder attentionLong context windows
Seasonal naive and NPTSNon-learned baselinesSanity checks and benchmarks
Representative model families in GluonTS

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.

MetricTypeWhat it measures
MASEPoint, scaledError relative to a seasonal naive forecast
sMAPEPoint, percentageSymmetric relative error
Weighted quantile lossProbabilisticAccuracy at chosen quantiles
Mean weighted quantile lossProbabilisticApproximation of CRPS across quantiles
CoverageCalibrationShare of observations below each quantile
Common metrics reported by the GluonTS evaluator

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.

ToolPrimary focusWhen to choose it
GluonTSProbabilistic deep-learning modelsMany related series, uncertainty needed
ProphetAdditive trend and seasonality modelSingle business series with holidays
sktimeUnified interface for many time series tasksClassical models and classification
AutoGluon-TimeSeriesAutomated ensembles built partly on GluonTSStrong results with little tuning
Chronos and other foundation modelsPretrained zero-shot forecastersNo training data per task
GluonTS and related forecasting tools

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.