gluonts.model.predictor module#

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

Bases: gluonts.model.predictor.Predictor

classmethod from_predictor(base: gluonts.model.predictor.RepresentablePredictor, **overrides) gluonts.model.predictor.Predictor[source]#
class gluonts.model.predictor.Localizer(estimator: Estimator)[source]#

Bases: gluonts.model.predictor.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: gluonts.dataset.Dataset, **kwargs) Iterator[gluonts.model.forecast.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: gluonts.model.predictor.Predictor, num_workers: Optional[int] = None, chunk_size=1)[source]#

Bases: gluonts.model.predictor.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: gluonts.dataset.Dataset, **kwargs) Iterator[gluonts.model.forecast.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: pathlib.Path, **kwargs) gluonts.model.predictor.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: gluonts.dataset.Dataset, **kwargs) Iterator[gluonts.model.forecast.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: pathlib.Path) None[source]#
class gluonts.model.predictor.RepresentablePredictor(prediction_length: int, lead_time: int = 0)[source]#

Bases: gluonts.model.predictor.Predictor

An abstract predictor that can be subclassed by models that are not based on Gluon. Subclasses should have @validated() constructors. (De)serialization and value equality are all implemented on top of the.

@validated() logic. :param prediction_length: Prediction horizon.

classmethod deserialize(path: pathlib.Path) gluonts.model.predictor.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: gluonts.dataset.Dataset, **kwargs) Iterator[gluonts.model.forecast.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]) gluonts.model.forecast.Forecast[source]#
serialize(path: pathlib.Path) None[source]#
class gluonts.model.predictor.WorkerError(msg)[source]#

Bases: object

gluonts.model.predictor.fallback(fallback_cls: Type[gluonts.model.predictor.FallbackPredictor])[source]#