gluonts.mx.model.deepar package#
- class gluonts.mx.model.deepar.DeepAREstimator(freq: str, prediction_length: int, trainer: gluonts.mx.trainer._base.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: typing.Optional[int] = None, num_layers: int = 2, num_cells: int = 40, cell_type: str = 'lstm', dropoutcell_type: str = 'ZoneoutCell', dropout_rate: float = 0.1, use_feat_dynamic_real: bool = False, use_feat_static_cat: bool = False, use_feat_static_real: bool = False, cardinality: typing.Optional[typing.List[int]] = None, embedding_dimension: typing.Optional[typing.List[int]] = None, distr_output: gluonts.mx.distribution.distribution_output.DistributionOutput = gluonts.mx.distribution.student_t.StudentTOutput(), scaling: bool = True, lags_seq: typing.Optional[typing.List[int]] = None, time_features: typing.Optional[typing.List[typing.Callable[[pandas.core.indexes.period.PeriodIndex], numpy.ndarray]]] = None, num_parallel_samples: int = 100, imputation_method: typing.Optional[gluonts.transform.feature.MissingValueImputation] = None, train_sampler: typing.Optional[gluonts.transform.sampler.InstanceSampler] = None, validation_sampler: typing.Optional[gluonts.transform.sampler.InstanceSampler] = None, dtype: typing.Type = <class 'numpy.float32'>, alpha: float = 0.0, beta: float = 0.0, batch_size: int = 32, default_scale: typing.Optional[float] = None, minimum_scale: float = 1e-10, impute_missing_values: bool = False, num_imputation_samples: int = 1, nonnegative_pred_samples: bool = False)[source]#
Bases:
gluonts.mx.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 (int) – 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’)
dropoutcell_type – Type of dropout cells to use (available: ‘ZoneoutCell’, ‘RNNZoneoutCell’, ‘VariationalDropoutCell’ or ‘VariationalZoneoutCell’; default: ‘ZoneoutCell’)
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)use_feat_static_real – Whether to use the
feat_static_real
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 (default: [min(50, (cat+1)//2) for cat in cardinality])
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)
imputation_method – One of the methods from ImputationStrategy
train_sampler – Controls the sampling of windows during training.
validation_sampler – Controls the sampling of windows during validation.
alpha – The scaling coefficient of the activation regularization
beta – The scaling coefficient of the temporal activation regularization
batch_size – The size of the batches to be used training and prediction.
minimum_scale – The minimum scale that is returned by the MeanScaler
default_scale – Default scale that is applied if the context length window is completely unobserved. If not set, the scale in this case will be the mean scale in the batch.
impute_missing_values – Whether to impute the missing values during training by using the current model parameters. Recommended if the dataset contains many missing values. However, this is a lot slower than the default mode.
num_imputation_samples – How many samples to use to impute values when impute_missing_values=True
nonnegative_pred_samples – Should final prediction samples be non-negative? If yes, an activation function is applied to ensure non-negative. Observe that this is applied only to the final samples and this is not applied during training.
- create_predictor(transformation: gluonts.transform._base.Transformation, trained_network: mxnet.gluon.block.HybridBlock) gluonts.model.predictor.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
- create_training_data_loader(data: gluonts.dataset.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() gluonts.mx.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._base.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
- create_validation_data_loader(data: gluonts.dataset.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
- lead_time: int#
- prediction_length: int#