gluonts.transform.feature module

class gluonts.transform.feature.AddAgeFeature(target_field: str, output_field: str, pred_length: int, log_scale: bool = True, dtype: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Bases: gluonts.transform._base.MapTransformation

Adds an ‘age’ feature to the data_entry.

The age feature starts with a small value at the start of the time series and grows over time.

If is_train=True the age feature has the same length as the target field. If is_train=False the age feature has length len(target) + pred_length

Parameters
  • target_field – Field with target values (array) of time series

  • output_field – Field name to use for the output.

  • pred_length – Prediction length

  • log_scale – If set to true the age feature grows logarithmically otherwise linearly over time.

map_transform(data: Dict[str, Any], is_train: bool) → Dict[str, Any][source]
class gluonts.transform.feature.AddAggregateLags(target_field: str, output_field: str, pred_length: int, base_freq: str, agg_freq: str, agg_lags: List[int], agg_fun: str = 'mean', rolling_agg: bool = True, dtype: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Bases: gluonts.transform._base.MapTransformation

Adds aggregate lags as a feature to the data_entry.

Aggregates the original time series to a new frequency and selects the aggregated lags of interest. It does not use aggregate lags that need the last prediction_length values to be computed. Therefore the transformation is applicable to both training and inference.

If is_train=True the lags have the same length as the target field. If is_train=False the lags have length len(target) + pred_length

Parameters
  • target_field – Field with target values (array) of time series

  • output_field – Field name to use for the output.

  • pred_length – Prediction length.

  • base_freq – Base frequency, i.e., the frequency of the original time series.

  • agg_freq – Aggregate frequency, i.e., the frequency of the aggregate time series.

  • agg_lags – List of aggregate lags given in the aggregate frequncy. If some of them are invalid (need some of the last prediction_length values to be computed) they are ignored.

  • agg_fun – Aggregation function. Default is ‘mean’.

  • rolling_agg – Boolean indicating if the aggregation should be done in a centered rolling window fashion (default) or by calendar dates.

map_transform(data: Dict[str, Any], is_train: bool) → Dict[str, Any][source]
class gluonts.transform.feature.AddConstFeature(output_field: str, target_field: str, pred_length: int, const: float = 1.0, dtype: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Bases: gluonts.transform._base.MapTransformation

Expands a const value along the time axis as a dynamic feature, where the T-dimension is defined as the sum of the pred_length parameter and the length of a time series specified by the target_field.

If is_train=True the feature matrix has the same length as the target field. If is_train=False the feature matrix has length len(target) + pred_length

Parameters
  • output_field – Field name for output.

  • target_field – Field containing the target array. The length of this array will be used.

  • pred_length – Prediction length (this is necessary since features have to be available in the future)

  • const – Constant value to use.

  • dtype – Numpy dtype to use for resulting array.

map_transform(data: Dict[str, Any], is_train: bool) → Dict[str, Any][source]
class gluonts.transform.feature.AddObservedValuesIndicator(target_field: str, output_field: str, imputation_method: Optional[gluonts.transform.feature.MissingValueImputation] = gluonts.transform.feature.DummyValueImputation(dummy_value=0.0), dtype: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Bases: gluonts.transform._base.SimpleTransformation

Replaces missing values in a numpy array (NaNs) with a dummy value and adds an “observed”-indicator that is 1 when values are observed and 0 when values are missing.

Parameters
  • target_field – Field for which missing values will be replaced

  • output_field – Field name to use for the indicator

  • imputation_method – One of the methods from ImputationStrategy. If set to None, no imputation is done and only the indicator is included.

transform(data: Dict[str, Any]) → Dict[str, Any][source]
class gluonts.transform.feature.AddTimeFeatures(start_field: str, target_field: str, output_field: str, time_features: List[gluonts.time_feature._base.TimeFeature], pred_length: int)[source]

Bases: gluonts.transform._base.MapTransformation

Adds a set of time features.

If is_train=True the feature matrix has the same length as the target field. If is_train=False the feature matrix has length len(target) + pred_length

Parameters
  • start_field – Field with the start time stamp of the time series

  • target_field – Field with the array containing the time series values

  • output_field – Field name for result.

  • time_features – list of time features to use.

  • pred_length – Prediction length

map_transform(data: Dict[str, Any], is_train: bool) → Dict[str, Any][source]
class gluonts.transform.feature.CausalMeanValueImputation[source]

Bases: gluonts.transform.feature.MissingValueImputation

This class replaces each missing value with the average of all the values up to this point. (If the first values are missing, they are replaced by the closest non missing value.)

class gluonts.transform.feature.DummyValueImputation(dummy_value: float = 0.0)[source]

Bases: gluonts.transform.feature.MissingValueImputation

This class replaces all the missing values with the same dummy value given in advance.

class gluonts.transform.feature.LastValueImputation[source]

Bases: gluonts.transform.feature.MissingValueImputation

This class replaces each missing value with the last value that was not missing. (If the first values are missing, they are replaced by the closest non missing value.)

class gluonts.transform.feature.LeavesMissingValues[source]

Bases: gluonts.transform.feature.MissingValueImputation

Just leaves the missing values untouched.

class gluonts.transform.feature.MeanValueImputation[source]

Bases: gluonts.transform.feature.MissingValueImputation

This class replaces all the missing values with the mean of the non missing values. Careful this is not a ‘causal’ method in the sense that it leaks information about the furture in the imputation. You may prefer to use CausalMeanValueImputation instead.

class gluonts.transform.feature.MissingValueImputation[source]

Bases: object

The parent class for all the missing value imputation classes. You can just implement your own inheriting this class.

class gluonts.transform.feature.RollingMeanValueImputation(window_size: int = 10)[source]

Bases: gluonts.transform.feature.MissingValueImputation

This class replaces each missing value with the average of all the last window_size (default=10) values. (If the first values are missing, they are replaced by the closest non missing value.)

gluonts.transform.feature.target_transformation_length(target: numpy.array, pred_length: int, is_train: bool) → int[source]