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.
| Component | Role | Typical setting |
|---|---|---|
| Recurrent encoder | Summarizes history in a hidden state | 2-3 LSTM layers, 40-128 units |
| Likelihood head | Maps hidden state to distribution parameters | Gaussian, negative binomial or Student’s t |
| Scale factor | Normalizes series of different magnitude | Mean of the context window plus one |
| Covariates | Add calendar and known future inputs | Day of week, month, promotions |
| Item embedding | Identifies the series or its category | Learned vector per categorical feature |
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 type | Recommended likelihood | Reason |
|---|---|---|
| Real-valued, roughly symmetric | Gaussian | Simple and stable |
| Real-valued with heavy tails | Student’s t | Robust to outliers |
| Non-negative counts | Negative binomial | Models overdispersion |
| Sparse, intermittent demand | Negative binomial with care | Many zeros strain the fit |
| Strictly positive continuous | Gamma or log-transformed Gaussian | Prevents negative predictions |
How DeepAR compares with related forecasters
DeepAR sits between classical local models and modern attention-based forecasters. Its distinctive traits are the global training regime and the explicit parametric likelihood.
| Method | Model scope | Uncertainty output | Main strength |
|---|---|---|---|
| DeepAR | Global across series | Parametric distribution via sampling | Many related series, cold starts |
| ARIMA | One model per series | Analytic intervals | Interpretable, small data |
| ETS model | One model per series | Analytic or simulated intervals | Trend and seasonality, fast |
| N-BEATS | Global | Point forecasts by default | Strong univariate accuracy |
| Temporal Fusion Transformer | Global | Direct quantile outputs | Rich covariates, interpretability |
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.
| Symptom | Likely cause | Fix |
|---|---|---|
| Intervals too narrow | Wrong likelihood choice | Switch to Student’s t or negative binomial |
| Drift over long horizons | Recursive error accumulation | Shorten horizon or try a direct model |
| Slow inference | Hundreds of sample paths per series | Reduce samples or batch on GPU |
| Poor accuracy on one series | Too few related series | Use a local model such as ETS |
| Missed holiday peaks | No calendar covariates | Add holiday and event features |
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.