DeepARModel¶
- class DeepARModel(batch_size: int = 64, context_length: Optional[int] = None, max_epochs: int = 10, gpus: Union[int, List[int]] = 0, gradient_clip_val: float = 0.1, learning_rate: Optional[List[float]] = None, cell_type: str = 'LSTM', hidden_size: int = 10, rnn_layers: int = 2, dropout: float = 0.1, loss: Optional[pytorch_forecasting.metrics.DistributionLoss] = None, trainer_kwargs: Optional[Dict[str, Any]] = None, quantiles_kwargs: Optional[Dict[str, Any]] = None)[source]¶
Bases:
etna.models.nn.utils._DeepCopyMixin,etna.models.mixins.SaveNNMixin,etna.models.base.PredictionIntervalContextIgnorantAbstractModelWrapper for
pytorch_forecasting.models.deepar.DeepAR.Notes
We save
pytorch_forecasting.data.timeseries.TimeSeriesDataSetin instance to use it in the model. It`s not right pattern of using Transforms and TSDataset.Initialize DeepAR wrapper.
- Parameters
batch_size (int) – Batch size.
context_length (Optional[int]) – Max encoder length, if None max encoder length is equal to 2 horizons.
max_epochs (int) – Max epochs.
gpus (Union[int, List[int]]) – 0 - is CPU, or [n_{i}] - to choose n_{i} GPU from cluster.
gradient_clip_val (float) – Clipping by norm is using, choose 0 to not clip.
learning_rate (Optional[List[float]]) – Learning rate.
cell_type (str) – One of ‘LSTM’, ‘GRU’.
hidden_size (int) – Hidden size of network which can range from 8 to 512.
rnn_layers (int) – Number of LSTM layers.
dropout (float) – Dropout rate.
loss (Optional[DistributionLoss]) – Distribution loss function. Keep in mind that each distribution loss function might have specific requirements for target normalization. Defaults to
pytorch_forecasting.metrics.NormalDistributionLoss.trainer_kwargs (Optional[Dict[str, Any]]) – Additional arguments for pytorch_lightning Trainer.
quantiles_kwargs (Optional[Dict[str, Any]]) – Additional arguments for computing quantiles, look at
to_quantiles()method for your loss.
- Inherited-members
Methods
fit(ts)Fit model.
forecast(ts[, prediction_interval, quantiles])Make predictions.
Get internal model that is used inside etna class.
load(path)Load an object.
predict(ts[, prediction_interval, quantiles])Make predictions.
save(path)Save the object.
to_dict()Collect all information about etna object in dict.
Attributes
context_size- fit(ts: etna.datasets.tsdataset.TSDataset) etna.models.nn.deepar.DeepARModel[source]¶
Fit model.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – TSDataset to fit.
- Return type
- forecast(ts: etna.datasets.tsdataset.TSDataset, prediction_interval: bool = False, quantiles: Sequence[float] = (0.025, 0.975)) etna.datasets.tsdataset.TSDataset[source]¶
Make predictions.
This method will make autoregressive predictions.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_interval (bool) – If True returns prediction interval for forecast
quantiles (Sequence[float]) – Levels of prediction distribution. By default 2.5% and 97.5% are taken to form a 95% prediction interval
- Returns
TSDataset with predictions.
- Return type
- get_model() Any[source]¶
Get internal model that is used inside etna class.
Internal model is a model that is used inside etna to forecast segments, e.g.
catboost.CatBoostRegressororsklearn.linear_model.Ridge.- Returns
Internal model
- Return type
Any
- predict(ts: etna.datasets.tsdataset.TSDataset, prediction_interval: bool = False, quantiles: Sequence[float] = (0.025, 0.975)) etna.datasets.tsdataset.TSDataset[source]¶
Make predictions.
This method will make predictions using true values instead of predicted on a previous step. It can be useful for making in-sample forecasts.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_interval (bool) – If True returns prediction interval for forecast
quantiles (Sequence[float]) – Levels of prediction distribution. By default 2.5% and 97.5% are taken to form a 95% prediction interval
- Returns
TSDataset with predictions.
- Return type