gluonts.transform.convert module

class gluonts.transform.convert.AsNumpyArray(field: str, expected_ndim: int, dtype: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Bases: gluonts.transform._base.SimpleTransformation

Converts the value of a field into a numpy array.

Parameters
  • expected_ndim – Expected number of dimensions. Throws an exception if the number of dimensions does not match.

  • dtype – numpy dtype to use.

transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.convert.CDFtoGaussianTransform(target_dim: int, target_field: str, observed_values_field: str, cdf_suffix='_cdf', max_context_length: Optional[int] = None)[source]

Bases: gluonts.transform._base.MapTransformation

Marginal transformation that transforms the target via an empirical CDF to a standard gaussian as described here: https://arxiv.org/abs/1910.03002

To be used in conjunction with a multivariate gaussian to from a copula. Note that this transformation is currently intended for multivariate targets only.

map_transform(data: Dict[str, Any], is_train: bool) → Dict[str, Any][source]
static standard_gaussian_cdf(x: numpy.array) → numpy.array[source]
static standard_gaussian_ppf(y: numpy.array) → numpy.array[source]
static winsorized_cutoff(m: numpy.array) → numpy.array[source]

Apply truncation to the empirical CDF estimator to reduce variance as described here: https://arxiv.org/abs/0903.0649

Parameters

m – Input array with empirical CDF values.

Returns

Truncated empirical CDf values.

Return type

res

class gluonts.transform.convert.ConcatFeatures(output_field: str, input_fields: List[str], drop_inputs: bool = True)[source]

Bases: gluonts.transform._base.SimpleTransformation

Concatenate fields together using np.concatenate.

Fields with value None are ignored.

Parameters
  • output_field – Field name to use for the output

  • input_fields – Fields to stack together

  • drop_inputs – If set to true the input fields will be dropped.

transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.convert.ExpandDimArray(field: str, axis: Optional[int] = None)[source]

Bases: gluonts.transform._base.SimpleTransformation

Expand dims in the axis specified, if the axis is not present does nothing. (This essentially calls np.expand_dims)

Parameters
  • field – Field in dictionary to use

  • axis – Axis to expand (see np.expand_dims for details)

transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.convert.ListFeatures(output_field: str, input_fields: List[str], drop_inputs: bool = True)[source]

Bases: gluonts.transform._base.SimpleTransformation

Creates a new field which contains a list of features.

Parameters
  • output_field – Field name for output

  • input_fields – Fields to combine into list

  • drop_inputs – If true the input fields will be removed from the result.

transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.convert.SampleTargetDim(field_name: str, target_field: str, observed_values_field: str, num_samples: int, shuffle: bool = True)[source]

Bases: gluonts.transform._base.FlatMapTransformation

Samples random dimensions from the target at training time.

flatmap_transform(data: Dict[str, Any], is_train: bool, slice_future_target: bool = True) → Iterator[Dict[str, Any]][source]
class gluonts.transform.convert.SwapAxes(input_fields: List[str], axes: Tuple[int, int])[source]

Bases: gluonts.transform._base.SimpleTransformation

Apply np.swapaxes to fields.

Parameters
  • input_fields – Field to apply to

  • axes – Axes to use

swap(v)[source]
transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.convert.TargetDimIndicator(field_name: str, target_field: str)[source]

Bases: gluonts.transform._base.SimpleTransformation

Label-encoding of the target dimensions.

transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.convert.VstackFeatures(output_field: str, input_fields: List[str], drop_inputs: bool = True)[source]

Bases: gluonts.transform._base.SimpleTransformation

Stack fields together using np.vstack.

Fields with value None are ignored.

Parameters
  • output_field – Field name to use for the output

  • input_fields – Fields to stack together

  • drop_inputs – If set to true the input fields will be dropped.

transform(data: Dict[str, Any]) → Dict[str, Any][source]
gluonts.transform.convert.cdf_to_gaussian_forward_transform(input_batch: Dict[str, Any], outputs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → numpy.ndarray[source]

Forward transformation of the CDFtoGaussianTransform.

Parameters
  • input_batch – Input data to the predictor.

  • outputs – Predictor outputs.

Returns

Forward transformed outputs.

Return type

outputs