gluonts.model.tpp package

class gluonts.model.tpp.PointProcessGluonPredictor(input_names: List[str], prediction_net: mxnet.gluon.block.Block, batch_size: int, prediction_interval_length: float, freq: str, ctx: mxnet.context.Context, input_transform: gluonts.transform._base.Transformation, dtype: gluonts.core.component.DType = <class 'numpy.float32'>, forecast_generator: gluonts.model.forecast_generator.ForecastGenerator = <gluonts.model.tpp.predictor.PointProcessForecastGenerator object>, **kwargs)[source]

Bases: gluonts.model.predictor.GluonPredictor

Predictor object for marked temporal point process models.

TPP predictions differ from standard discrete-time models in several regards. First, at least for now, only sample forecasts implementing PointProcessSampleForecast are available. Similar to TPP Estimator objects, the Predictor works with prediction_interval_length as opposed to prediction_length.

The predictor also accounts for the fact that the prediction network outputs a 2-tuple of Tensors, for the samples themselves and their valid_length.

Finally, this class uses a VariableLengthInferenceDataLoader as opposed to the default InferenceDataLoader.


prediction_interval_length – The length of the prediction interval

as_symbol_block_predictor(batch: Dict[str, Any]) → gluonts.model.predictor.SymbolBlockPredictor[source]

Returns a variant of the current GluonPredictor backed by a Gluon SymbolBlock. If the current predictor is already a SymbolBlockPredictor, it just returns itself.


batch – A batch of data to use for the required forward pass after the hybridize() call of the underlying network.


A predictor derived from the current one backed by a SymbolBlock.

Return type


hybridize(batch: Dict[str, Any]) → None[source]

Hybridizes the underlying prediction network.


batch – A batch of data to use for the required forward pass after the hybridize() call.

predict(dataset: Iterable[Dict[str, Any]], num_samples: Optional[int] = None, num_workers: Optional[int] = None, num_prefetch: Optional[int] = None, **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.


dataset – The dataset containing the time series to predict.


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

Return type


serialize_prediction_net(path: pathlib.Path) → None[source]
class gluonts.model.tpp.PointProcessSampleForecast(samples: Union[mxnet.ndarray.ndarray.NDArray, numpy.ndarray], valid_length: Union[mxnet.ndarray.ndarray.NDArray, numpy.ndarray], start_date: pandas._libs.tslibs.timestamps.Timestamp, freq: str, prediction_interval_length: float, item_id: Optional[str] = None, info: Optional[Dict] = None)[source]

Bases: gluonts.model.forecast.Forecast

Sample forecast object used for temporal point process inference. Differs from standard forecast objects as it does not implement fixed length samples. Each sample has a variable length, that is kept in a separate valid_length attribute.

Importantly, PointProcessSampleForecast does not implement some methods (such as quantile or plot) that are available in discrete time forecasts.

  • samples – A multidimensional array of samples, of shape (number_of_samples, max_pred_length, target_dim) or (number_of_samples, max_pred_length). For marked TPP, the target_dim is 2 with the first element keeping interarrival times and the second keeping marks. If samples are two-dimensional, each entry stands for the interarrival times in a (unmarked) TPP sample.

  • valid_length – An array of integers denoting the valid lengths of each sample in samples. That is, valid_length[0] == 2 implies that only the first two entries of samples[0, ...] are valid “points”.

  • start_date – Starting timestamp of the sample

  • freq – The time unit of interarrival times

  • prediction_interval_length – The length of the prediction interval for which samples were drawn.

  • item_id – Item ID, if available.

  • info – Optional dictionary of additional information.

as_json_dict(config: gluonts.model.forecast.Config) → dict[source]
dim() → int[source]

Returns the dimensionality of the forecast object.

property index
mean = None

Plots the median of the forecast as well as confidence bounds. (requires matplotlib and pandas).

  • prediction_intervals (float or list of floats in [0, 100]) – Confidence interval size(s). If a list, it will stack the error plots for each confidence interval. Only relevant for error styles with “ci” in the name.

  • show_mean (boolean) – Whether to also show the mean of the forecast.

  • color (matplotlib color name or dictionary) – The color used for plotting the forecast.

  • label (string) – A label (prefix) that is used for the forecast

  • output_file (str or None, default None) – Output path for the plot file. If None, plot is not saved to file.

  • args – Other arguments are passed to main plot() call

  • kwargs – Other keyword arguments are passed to main plot() call

prediction_interval_length: float = None
prediction_length = None
quantile(q: Union[float, str]) → numpy.ndarray[source]

Computes a quantile from the predicted distribution.


q – Quantile to compute.


Value of the quantile across the prediction range.

Return type