Skip to main content
The DeepAR model produces probabilistic forecasts based on an autoregressive recurrent neural network optimized on panel data using cross-learning. DeepAR obtains its forecast distribution uses a Markov Chain Monte Carlo sampler with the following conditional probability: P(y[t+1:t+H]  y[:t],  x[:t+H](f),  x(s))\mathbb{P}(\mathbf{y}_{[t+1:t+H]}|\;\mathbf{y}_{[:t]},\; \mathbf{x}^{(f)}_{[:t+H]},\; \mathbf{x}^{(s)}) where x(s)\mathbf{x}^{(s)} are static exogenous inputs, x[:t+H](f)\mathbf{x}^{(f)}_{[:t+H]} are future exogenous available at the time of the prediction. The predictions are obtained by transforming the hidden states ht\mathbf{h}_{t} into predictive distribution parameters θt\theta_{t}, and then generating samples y^[t+1:t+H]\mathbf{\hat{y}}_{[t+1:t+H]} through Monte Carlo sampling trajectories. ht=RNN([yt,xt+1(f),x(s)],ht1)θt=Linear(ht)y^t+1=sample(  P(yt+1    θt)  ) \begin{align} \mathbf{h}_{t} &= \textrm{RNN}([\mathbf{y}_{t},\mathbf{x}^{(f)}_{t+1},\mathbf{x}^{(s)}], \mathbf{h}_{t-1})\\ \mathbf{\theta}_{t}&=\textrm{Linear}(\mathbf{h}_{t}) \\ \hat{y}_{t+1}&=\textrm{sample}(\;\mathrm{P}(y_{t+1}\;|\;\mathbf{\theta}_{t})\;) \end{align} References
Exogenous Variables, Losses, and Parameters Availability Given the sampling procedure during inference, DeepAR only supports DistributionLoss as training loss. Note that DeepAR generates a non-parametric forecast distribution using Monte Carlo. We use this sampling procedure also during validation to make it closer to the inference procedure. Therefore, only the MQLoss is available for validation. Aditionally, Monte Carlo implies that historic exogenous variables are not available for the model.
Figure 1. DeepAR model, during training the optimization signal comes from likelihood of observations, during inference a recurrent multi-step strategy is used to generate predictive distributions. Figure 1. DeepAR model, during training the optimization signal comes from likelihood of observations, during inference a recurrent multi-step strategy is used to generate predictive distributions.

1. DeepAR

DeepAR

Bases: BaseModel DeepAR Parameters:

DeepAR.fit

Fit. The fit method, optimizes the neural network’s weights using the initialization parameters (learning_rate, windows_batch_size, …) and the loss function as defined during the initialization. Within fit we use a PyTorch Lightning Trainer that inherits the initialization’s self.trainer_kwargs, to customize its inputs, see PL’s trainer arguments. The method is designed to be compatible with SKLearn-like classes and in particular to be compatible with the StatsForecast library. By default the model is not saving training checkpoints to protect disk memory, to get them change enable_checkpointing=True in __init__. Parameters: Returns:

DeepAR.predict

Predict. Neural network prediction with PL’s Trainer execution of predict_step. Parameters: Returns:

Usage Example

2. Auxiliary functions

Decoder

Bases: Module Multi-Layer Perceptron Decoder Parameters: