gluonts.mx.model.deep_factor package#

class gluonts.mx.model.deep_factor.DeepFactorEstimator(freq: str, prediction_length: int, num_hidden_global: int = 50, num_layers_global: int = 1, num_factors: int = 10, num_hidden_local: int = 5, num_layers_local: int = 1, cell_type: str = 'lstm', trainer: Trainer = gluonts.mx.trainer._base.Trainer(add_default_callbacks=True, callbacks=None, clip_gradient=10.0, ctx=None, epochs=100, hybridize=True, init='xavier', learning_rate=0.001, num_batches_per_epoch=50, weight_decay=1e-08), context_length: Optional[int] = None, num_parallel_samples: int = 100, cardinality: List[int] = [1], embedding_dimension: int = 10, distr_output: DistributionOutput = gluonts.mx.distribution.student_t.StudentTOutput(), batch_size: int = 32)[source]#

Bases: GluonEstimator

DeepFactorEstimator is an implementation of the 2019 ICML paper “Deep Factors for Forecasting” https://arxiv.org/abs/1905.12417. It uses a global RNN model to learn patterns across multiple related time series and an arbitrary local model to model the time series on a per time series basis. In the current implementation, the local model is a RNN (DF-RNN).

Parameters:
  • freq – Time series frequency.

  • prediction_length (int) – Prediction length.

  • num_hidden_global – Number of units per hidden layer for the global RNN model (default: 50).

  • num_layers_global – Number of hidden layers for the global RNN model (default: 1).

  • num_factors – Number of global factors (default: 10).

  • num_hidden_local – Number of units per hidden layer for the local RNN model (default: 5).

  • num_layers_local – Number of hidden layers for the global local model (default: 1).

  • cell_type – Type of recurrent cells to use (available: ‘lstm’ or ‘gru’; default: ‘lstm’).

  • trainer – Trainer object to be used (default: Trainer()).

  • context_length – Training length (default: None, in which case context_length = prediction_length).

  • 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).

  • cardinality – List consisting of the number of time series (default: list([1]).

  • embedding_dimension – Dimension of the embeddings for categorical features (the same dimension is used for all embeddings, default: 10).

  • distr_output – Distribution to use to evaluate observations and sample predictions (default: StudentTOutput()).

  • batch_size – The size of the batches to be used training and prediction.

create_predictor(transformation: Transformation, trained_network: DeepFactorTrainingNetwork) Predictor[source]#

Create and return a predictor object.

Parameters:
  • transformation – Transformation to be applied to data before it goes into the model.

  • module – A trained HybridBlock object.

Returns:

A predictor wrapping a HybridBlock used for inference.

Return type:

Predictor

create_training_data_loader(data: Dataset, **kwargs) Iterable[Dict[str, Any]][source]#

Create a data loader for training purposes.

Parameters:

data – Dataset from which to create the data loader.

Returns:

The data loader, i.e. and iterable over batches of data.

Return type:

DataLoader

create_training_network() DeepFactorTrainingNetwork[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() 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

create_validation_data_loader(data: Dataset, **kwargs) Iterable[Dict[str, Any]][source]#

Create a data loader for validation purposes.

Parameters:

data – Dataset from which to create the data loader.

Returns:

The data loader, i.e. and iterable over batches of data.

Return type:

DataLoader

Submodules#