gluonts.model.predictor module#

class gluonts.model.predictor.Localizer(estimator: Estimator)[source]#

Bases: Predictor

A Predictor that uses an estimator to train a local model per time series and immediately calls this to predict.

Parameters

estimator – The estimator object to train on each dataset entry at prediction time.

predict(dataset: Dataset, **kwargs) Iterator[Forecast][source]#

Compute forecasts for the time series in the provided dataset. This method is not implemented in this abstract class; please use one of the subclasses. :param dataset: The dataset containing the time series to predict.

Returns

Iterator over the forecasts, in the same order as the dataset iterable was provided.

Return type

Iterator[Forecast]

class gluonts.model.predictor.ParallelizedPredictor(base_predictor: Predictor, num_workers: Optional[int] = None, chunk_size=1)[source]#

Bases: Predictor

Runs multiple instances (workers) of a predictor in parallel. Exceptions are propagated from the workers. Note: That there is currently an issue with tqdm that will cause things to hang if the ParallelizedPredictor is used with tqdm and an exception occurs during prediction. https://github.com/tqdm/tqdm/issues/548

Parameters
  • base_predictor – A representable predictor that will be used

  • num_workers – Number of workers (processes) to use. If set to None, one worker per CPU will be used.

  • chunk_size – Number of items to pass per call

predict(dataset: Dataset, **kwargs) Iterator[Forecast][source]#

Compute forecasts for the time series in the provided dataset. This method is not implemented in this abstract class; please use one of the subclasses. :param dataset: The dataset containing the time series to predict.

Returns

Iterator over the forecasts, in the same order as the dataset iterable was provided.

Return type

Iterator[Forecast]

terminate()[source]#
class gluonts.model.predictor.Predictor(prediction_length: int, lead_time: int = 0)[source]#

Bases: object

Abstract class representing predictor objects. :param prediction_length: Prediction horizon.

classmethod derive_auto_fields(train_iter)[source]#
classmethod deserialize(path: Path, **kwargs) Predictor[source]#

Load a serialized predictor from the given path.

Parameters
  • path – Path to the serialized files predictor.

  • **kwargs – Optional context/device parameter to be used with the predictor. If nothing is passed will use the GPU if available and CPU otherwise.

classmethod from_hyperparameters(**hyperparameters)[source]#
classmethod from_inputs(train_iter, **params)[source]#
predict(dataset: Dataset, **kwargs) Iterator[Forecast][source]#

Compute forecasts for the time series in the provided dataset. This method is not implemented in this abstract class; please use one of the subclasses. :param dataset: The dataset containing the time series to predict.

Returns

Iterator over the forecasts, in the same order as the dataset iterable was provided.

Return type

Iterator[Forecast]

serialize(path: Path) None[source]#
class gluonts.model.predictor.RepresentablePredictor(prediction_length: int, lead_time: int = 0)[source]#

Bases: Predictor

An abstract predictor that can be subclassed by framework-specific models. Subclasses should have @validated() constructors: (de)serialization and equality test are all implemented on top of its logic.

Parameters
  • prediction_length – Prediction horizon.

  • lead_time – Prediction lead time.

classmethod deserialize(path: Path) RepresentablePredictor[source]#

Load a serialized predictor from the given path.

Parameters
  • path – Path to the serialized files predictor.

  • **kwargs – Optional context/device parameter to be used with the predictor. If nothing is passed will use the GPU if available and CPU otherwise.

predict(dataset: Dataset, **kwargs) Iterator[Forecast][source]#

Compute forecasts for the time series in the provided dataset. This method is not implemented in this abstract class; please use one of the subclasses. :param dataset: The dataset containing the time series to predict.

Returns

Iterator over the forecasts, in the same order as the dataset iterable was provided.

Return type

Iterator[Forecast]

predict_item(item: Dict[str, Any]) Forecast[source]#
serialize(path: Path) None[source]#
class gluonts.model.predictor.WorkerError(msg)[source]#

Bases: object