Table Of Contents
Table Of Contents

gluonts.model.deepar package

class gluonts.model.deepar.DeepAREstimator(freq: str, prediction_length: int, trainer: gluonts.trainer._base.Trainer = gluonts.trainer._base.Trainer(batch_size=32, clip_gradient=10.0, ctx=None, epochs=100, hybridize=True, init="xavier", learning_rate=0.001, learning_rate_decay_factor=0.5, minimum_learning_rate=5e-05, num_batches_per_epoch=50, patience=10, weight_decay=1e-08), context_length: Optional[int] = None, num_layers: int = 2, num_cells: int = 40, cell_type: str = 'lstm', dropout_rate: float = 0.1, use_feat_dynamic_real: bool = False, use_feat_static_cat: bool = False, cardinality: Optional[List[int]] = None, embedding_dimension: int = 20, distr_output: gluonts.distribution.distribution_output.DistributionOutput = gluonts.distribution.student_t.StudentTOutput(), scaling: bool = True, lags_seq: Optional[List[int]] = None, time_features: Optional[List[gluonts.time_feature._base.TimeFeature]] = None, num_parallel_samples: int = 100)[source]

Bases: gluonts.model.estimator.GluonEstimator

Construct a DeepAR estimator.

This implements an RNN-based model, close to the one described in [SFG17].

Note: the code of this model is unrelated to the implementation behind SageMaker’s DeepAR Forecasting Algorithm.

Parameters:
  • freq – Frequency of the data to train on and predict
  • prediction_length – Length of the prediction horizon
  • trainer – Trainer object to be used (default: Trainer())
  • context_length – Number of steps to unroll the RNN for before computing predictions (default: None, in which case context_length = prediction_length)
  • num_layers – Number of RNN layers (default: 2)
  • num_cells – Number of RNN cells for each layer (default: 40)
  • cell_type – Type of recurrent cells to use (available: ‘lstm’ or ‘gru’; default: ‘lstm’)
  • dropout_rate – Dropout regularization parameter (default: 0.1)
  • use_feat_dynamic_real – Whether to use the feat_dynamic_real field from the data (default: False)
  • use_feat_static_cat – Whether to use the feat_static_cat field from the data (default: False)
  • cardinality – Number of values of each categorical feature. This must be set if use_feat_static_cat == True (default: None)
  • embedding_dimension – Dimension of the embeddings for categorical features (the same dimension is used for all embeddings, default: 5)
  • distr_output – Distribution to use to evaluate observations and sample predictions (default: StudentTOutput())
  • scaling – Whether to automatically scale the target values (default: true)
  • lags_seq – Indices of the lagged target values to use as inputs of the RNN (default: None, in which case these are automatically determined based on freq)
  • time_features – Time features to use as inputs of the RNN (default: None, in which case these are automatically determined based on freq)
  • num_parallel_samples – Number of evaluation samples per time series to increase parallelism during inference. This is a model optimization that does not affect the accuracy (default: 100)
create_predictor(transformation: gluonts.transform.Transformation, trained_network: mxnet.gluon.block.HybridBlock) → gluonts.model.predictor.Predictor[source]

Create and return a predictor object.

Returns:A predictor wrapping a HybridBlock used for inference.
Return type:Predictor
create_training_network() → gluonts.model.deepar._network.DeepARTrainingNetwork[source]

Create and return the network used for training (i.e., computing the loss).

Returns:The network that computes the loss given input data.
Return type:HybridBlock
create_transformation() → gluonts.transform.Transformation[source]

Create and return the transformation needed for training and inference.

Returns:The transformation that will be applied entry-wise to datasets, at training and inference time.
Return type:Transformation