gluonts.representation module

class gluonts.representation.Representation[source]

Bases: mxnet.gluon.block.HybridBlock

An abstract class representing input/output representations.

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

initialize_from_array(input_array: numpy.ndarray, ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on a numpy array.

Parameters
  • input_array – Numpy array.

  • ctx – MXNet context.

initialize_from_dataset(input_dataset: Iterable[Dict[str, Any]], ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on an entire dataset.

Parameters
  • input_dataset – GluonTS dataset.

  • ctx – MXNet context.

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor

class gluonts.representation.CustomBinning(bin_centers: numpy.ndarray, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing binned representations with custom centers.

Parameters

bin_centers – The bins to be used to discretize the data. (default: 1024)

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

initialize_from_array(input_array: numpy.ndarray, ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on a numpy array.

Parameters
  • input_array – Numpy array.

  • ctx – MXNet context.

initialize_from_dataset(input_dataset: Iterable[Dict[str, Any]], ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on an entire dataset.

Parameters
  • input_dataset – GluonTS dataset.

  • ctx – MXNet context.

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor

class gluonts.representation.GlobalRelativeBinning(num_bins: int = 1024, is_quantile: bool = True, linear_scaling_limit: int = 10, quantile_scaling_limit: float = 0.99, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a global relative binning approach. This binning first rescales all input series by their respective mean (relative) and then performs one binning across all series (global).

Parameters
  • num_bins – The number of discrete bins/buckets that we want values to be mapped to. (default: 1024)

  • is_quantile – Whether the binning is quantile or linear. Quantile binning allocated bins based on the cumulative distribution function, while linear binning allocates evenly spaced bins. (default: True, i.e. quantile binning)

  • linear_scaling_limit – The linear scaling limit. Values which are larger than linear_scaling_limit times the mean will be capped at linear_scaling_limit. (default: 10)

  • quantile_scaling_limit – The quantile scaling limit. Values which are larger than the quantile evaluated at quantile_scaling_limit will be capped at the quantile evaluated at quantile_scaling_limit. (default: 0.99)

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

initialize_from_array(input_array: numpy.ndarray, ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on a numpy array.

Parameters
  • input_array – Numpy array.

  • ctx – MXNet context.

initialize_from_dataset(input_dataset: Iterable[Dict[str, Any]], ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on an entire dataset.

Parameters
  • input_dataset – GluonTS dataset.

  • ctx – MXNet context.

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor

class gluonts.representation.LocalAbsoluteBinning(num_bins: int = 1024, is_quantile: bool = True, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a local absolute binning approach. This binning estimates a binning for every single time series on a local level and therefore implicitly acts as a scaling mechanism.

Parameters
  • num_bins – The number of discrete bins/buckets that we want values to be mapped to. (default: 1024)

  • is_quantile – Whether the binning is quantile or linear. Quantile binning allocated bins based on the cumulative distribution function, while linear binning allocates evenly spaced bins. (default: True, i.e. quantile binning)

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor

class gluonts.representation.HybridRepresentation(representations: List, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a hybrid approach of combining multiple representations into a single representation. Representations will be combined by concatenating them on dim=-1.

Parameters

representations – A list of representations. Elements must be of type Representation.

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

initialize_from_array(input_array: numpy.ndarray, ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on a numpy array.

Parameters
  • input_array – Numpy array.

  • ctx – MXNet context.

initialize_from_dataset(input_dataset: Iterable[Dict[str, Any]], ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on an entire dataset.

Parameters
  • input_dataset – GluonTS dataset.

  • ctx – MXNet context.

class gluonts.representation.MeanScaling(scale_min: float = 1e-10, clip_max: Optional[float] = None, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a mean scaling approach. Inputs are simply rescaled based on their mean.

Parameters
  • minimum_scale – The minimum value to which re-scaled values will be clipped to. (default: 1e-10)

  • clip_max – The maximum value to which re-scaled values will be clipped to. Negative values will be clipped at -clip_max and positive values at clip_max. (default: None)

compute_scale(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor

class gluonts.representation.DimExpansion(axis: int = -1, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a dimension expansion operation along a specified axis.

Parameters

axis – Axis on which to expand the tensor. (default: -1)

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

class gluonts.representation.Embedding(num_bins: int, size: Optional[int] = None, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing an embedding operation on top of a given binning. Note that this representation is intended to applied on top of categorical/binned data.

Parameters
hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

class gluonts.representation.DiscretePIT(num_bins: int, mlp_transf: bool = False, embedding_size: Optional[int] = None, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a discrete probability integral transform of a given quantile-based learned binning. Note that this representation is intended to be applied on top of a quantile-based binning representation.

Parameters
  • num_bins – Number of bins used by the data on which this representation is applied.

  • mlp_tranf – Whether we want to post-process the pit-transformed valued using a MLP which can learn an appropriate binning, which would ensure that pit models have the same expressiveness as standard quantile binning with embedding. (default: False)

  • embedding_size – The desired layer output size if mlp_tranf=True. By default, the following heuristic is used: https://developers.googleblog.com/2017/11/introducing-tensorflow-feature-columns.html (default: round(num_bins**(1/4)))

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor

class gluonts.representation.RepresentationChain(chain: List, *args, **kwargs)[source]

Bases: gluonts.mx.representation.representation.Representation

A class representing a hybrid approach of combining multiple representations into a single representation. Representations will be combined by concatenating them on dim=-1.

Parameters

chain – A list of representations. Elements must be of type Representation.

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], **kwargs) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]][source]

Transform the data into the desired representation.

Parameters
  • F

  • data – Target data.

  • observed_indicator – Target observed indicator.

  • scale – Pre-computed scale.

  • rep_params – Additional pre-computed representation parameters.

  • **kwargs, – Additional block-specfic parameters.

Returns

Tuple consisting of the transformed data, the computed scale, and additional parameters to be passed to post_transform.

Return type

Tuple[Tensor, Tensor, List[Tensor]]

initialize_from_array(input_array: numpy.ndarray, ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on a numpy array.

Parameters
  • input_array – Numpy array.

  • ctx – MXNet context.

initialize_from_dataset(input_dataset: Iterable[Dict[str, Any]], ctx: mxnet.context.Context = gpu(0))[source]

Initialize the representation based on an entire dataset.

Parameters
  • input_dataset – GluonTS dataset.

  • ctx – MXNet context.

post_transform(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rep_params: List[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Transform samples back to the original representation.

Parameters
  • samples – Samples from a distribution.

  • scale – The scale of the samples.

  • rep_params – Additional representation-specific parameters used during post transformation.

Returns

Post-transformed samples.

Return type

Tensor