DeepAR

On this page 7

DeepAR is a probabilistic forecasting method based on an autoregressive recurrent neural network, introduced by researchers at Amazon in 2017, that learns a single global model from many related time series and predicts a full probability distribution for each future step. In time series & forecasting, it is a landmark among deep-learning forecasters because it showed that one network trained on thousands of products can outperform separate classical models fitted to each series.

Instead of returning one number, DeepAR outputs the parameters of a likelihood function, such as the mean and variance of a Gaussian or the mean and dispersion of a negative binomial. Sampling from these distributions yields forecast quantiles and prediction intervals, which are essential for inventory, capacity and risk decisions.

How DeepAR generates forecasts

DeepAR processes each series step by step with a recurrent network, typically a stack of LSTM layers. At every time step, the network receives the previous observed value, the covariates for the current step and its own hidden state, and it emits the parameters of the predictive distribution for the current value.

Training uses teacher forcing: the true previous value is fed back as input, and the model maximizes the log-likelihood of the observed values over a conditioning range followed by a prediction range. At forecast time, the true future is unknown, so the model performs ancestral sampling: it draws a value, feeds it back as the next input and repeats until the horizon is reached.

Repeating this sampling several hundred times produces sample paths that describe the joint uncertainty over the horizon. Quantiles such as P10, P50 and P90 are then read directly from the samples.

ComponentRoleTypical setting
Recurrent encoderSummarizes history in a hidden state2-3 LSTM layers, 40-128 units
Likelihood headMaps hidden state to distribution parametersGaussian, negative binomial or Student’s t
Scale factorNormalizes series of different magnitudeMean of the context window plus one
CovariatesAdd calendar and known future inputsDay of week, month, promotions
Item embeddingIdentifies the series or its categoryLearned vector per categorical feature
Main components of a DeepAR model

Handling scale, counts and cold starts

A central challenge for a global forecasting model is that series differ in magnitude by several orders. DeepAR divides inputs by an item-dependent scale factor and multiplies the output parameters back, so the network learns shared temporal patterns rather than absolute levels.

Because high-volume series would dominate a uniform training sample, the original method draws training windows with probability proportional to scale. This weighted sampling keeps the model accurate on the important series without ignoring smaller ones.

For count data such as unit sales, the negative binomial likelihood captures overdispersion and keeps predictions non-negative. Since the network shares knowledge across items, DeepAR can forecast new products with short histories by relying on their embeddings and covariates, a capability known as handling the cold-start problem.

Data typeRecommended likelihoodReason
Real-valued, roughly symmetricGaussianSimple and stable
Real-valued with heavy tailsStudent’s tRobust to outliers
Non-negative countsNegative binomialModels overdispersion
Sparse, intermittent demandNegative binomial with careMany zeros strain the fit
Strictly positive continuousGamma or log-transformed GaussianPrevents negative predictions
Choosing a likelihood for DeepAR

DeepAR sits between classical local models and modern attention-based forecasters. Its distinctive traits are the global training regime and the explicit parametric likelihood.

MethodModel scopeUncertainty outputMain strength
DeepARGlobal across seriesParametric distribution via samplingMany related series, cold starts
ARIMAOne model per seriesAnalytic intervalsInterpretable, small data
ETS modelOne model per seriesAnalytic or simulated intervalsTrend and seasonality, fast
N-BEATSGlobalPoint forecasts by defaultStrong univariate accuracy
Temporal Fusion TransformerGlobalDirect quantile outputsRich covariates, interpretability
DeepAR compared with neighboring forecasting methods

Compared with direct multi-step strategies, DeepAR uses recursive forecasting, which keeps the model compact but can accumulate errors over long horizons. Quantile models such as the Temporal Fusion Transformer avoid sampling but do not provide coherent sample paths.

Practical configuration and evaluation

DeepAR is available as a built-in algorithm in Amazon SageMaker and as an open implementation in GluonTS, with ports in other forecasting libraries. Key choices include the context length, usually one to several seasonal cycles, and the prediction length, which must match the business horizon.

  • Provide calendar covariates such as day of week and holidays, because the network cannot infer them from short windows.
  • Use enough related series; the method shines with hundreds or thousands of items and offers little over ETS for a single series.
  • Evaluate probabilistically with weighted quantile loss, also called pinball loss, or the continuous ranked probability score, not only with MAPE.
  • Validate with time series cross-validation using rolling origins, never a random split.

Limitations and common mistakes

DeepAR is powerful but not a universal default. Its weaknesses come mostly from the recurrent architecture and the parametric assumption about the output distribution.

SymptomLikely causeFix
Intervals too narrowWrong likelihood choiceSwitch to Student’s t or negative binomial
Drift over long horizonsRecursive error accumulationShorten horizon or try a direct model
Slow inferenceHundreds of sample paths per seriesReduce samples or batch on GPU
Poor accuracy on one seriesToo few related seriesUse a local model such as ETS
Missed holiday peaksNo calendar covariatesAdd holiday and event features
Typical problems with DeepAR and how to address them

Another frequent misunderstanding is that sample paths capture cross-series correlation. Standard DeepAR models each series independently given its covariates, so aggregating forecasts for a hierarchical forecasting setup may need reconciliation.

The idea in brief

DeepAR is a forecasting model that learns from many similar histories at once. Imagine a store with ten thousand products. Instead of studying each product alone, DeepAR studies all of them together. It notices shared habits, such as busy weekends and holiday rushes.

It also does not give just one guess. It gives a range of likely outcomes, from a quiet week to a busy one. That range helps people decide how much stock to keep. The key idea is simple: shared learning plus honest uncertainty.

A practical scenario

A regional grocery chain with 120 stores and 8,000 products needs daily demand forecasts four weeks ahead. Many items sell only a few units per day, and new products appear every month. Separate ARIMA models for nearly one million store-item pairs proved slow and unreliable.

The analytics team trains one DeepAR model with a negative binomial likelihood, a context length of 56 days and covariates for weekday, holidays and planned promotions. Each store and product category receives an embedding. Replenishment orders are then set at the P85 quantile for perishable goods and P95 for staples.

After three months, the chain reports fewer stockouts and less waste than with its previous point forecasts. New products receive usable forecasts within their first week, because the model borrows patterns from similar items in the same category.