gluonts.dataset.hierarchical module#

class gluonts.dataset.hierarchical.HierarchicalTimeSeries(ts_at_bottom_level: pandas.core.frame.DataFrame, S: numpy.ndarray)[source]#

Bases: object

Class for representing hierarchical time series.

The hierarchy is represented by the standard aggregation matrix S. The time series at the bottom (leaf) level of the hierarchy (ts_at_bottom_level) are assumed to be given by the columns of a single pandas dataframe.

The ordering of columns of ts_at_bottom_level should be consistent with the ordering of the columns of S.

Parameters
  • ts_at_bottom_level – A single pandas dataframe whose columns are the time series corresponding to the leaves of the hierarchy.

  • S – Summation or aggregation matrix whose ordering should be consistent with the ordering of the columns of ts_at_all_levels. In particular, the bottom k x k sub-matrix should be identity matrix, where k is the number of leaves of the hierarchy.

property S#
static aggregate_ts(ts_at_bottom_level: pandas.core.frame.DataFrame, S: numpy.ndarray) pandas.core.frame.DataFrame[source]#

Constructs aggregated time series according to the summation/aggregation matrix S.

Parameters
  • ts_at_bottom_level – A single pandas dataframe whose columns are the time series corresponding to the leaves of the hierarchy.

  • S – Summation or aggregation matrix whose ordering should be consistent with the ordering of the columns of ts_at_all_levels. In particular, the bottom k x k sub-matrix should be an identity matrix, where k is the number of leaves of the hierarchy.

Returns

  • A pandas dataframe consisting of aggregated time series

  • (at all non-leaf levels).

property freq#
property num_bottom_ts#
property num_ts#
to_dataset(feat_dynamic_real: Optional[pandas.core.frame.DataFrame] = None)[source]#

Convert the hierarchical time series into gluonts.dataset.PandasDataset.

Note: Currently only dynamic real features are used by the hierarchical model. However, the model internally creates a categorical feature to distinguish between different time series of the hierarchy.

Parameters

feat_dynamic_real – A pandas dataframe containing dynamic features as columns. Note that features of any (or all) time series in the hierarchy can be passed here, since all time series are considered together as a single multivariate time series.

Returns

An instance of PandasDataset.

Return type

PandasDataset

property ts_at_all_levels#