Exemple #1
0
 def create_transformation(self) -> transform.Transformation:
     return transform.Chain(
         trans=[
             transform.AsNumpyArray(
                 field=FieldName.TARGET, expected_ndim=1
             ),
             transform.AddTimeFeatures(
                 start_field=transform.FieldName.START,
                 target_field=transform.FieldName.TARGET,
                 output_field=transform.FieldName.FEAT_TIME,
                 time_features=time_features_from_frequency_str(self.freq),
                 pred_length=self.prediction_length,
             ),
             transform.VstackFeatures(
                 output_field=FieldName.FEAT_DYNAMIC_REAL,
                 input_fields=[FieldName.FEAT_TIME],
             ),
             transform.SetFieldIfNotPresent(
                 field=FieldName.FEAT_STATIC_CAT, value=[0.0]
             ),
             transform.AsNumpyArray(
                 field=FieldName.FEAT_STATIC_CAT, expected_ndim=1
             ),
             transform.InstanceSplitter(
                 target_field=transform.FieldName.TARGET,
                 is_pad_field=transform.FieldName.IS_PAD,
                 start_field=transform.FieldName.START,
                 forecast_start_field=transform.FieldName.FORECAST_START,
                 train_sampler=ExpectedNumInstanceSampler(num_instances=1),
                 past_length=self.context_length,
                 future_length=self.prediction_length,
                 time_series_fields=[FieldName.FEAT_DYNAMIC_REAL],
             ),
         ]
     )
Exemple #2
0
 def create_transformation(self) -> transform.Transformation:
     return transform.Chain(
         trans=[
             transform.AsNumpyArray(
                 field=FieldName.TARGET, expected_ndim=1
             ),
             transform.AddTimeFeatures(
                 start_field=FieldName.START,
                 target_field=FieldName.TARGET,
                 output_field=FieldName.FEAT_TIME,
                 time_features=time_features_from_frequency_str(self.freq),
                 pred_length=self.prediction_length,
             ),
             transform.VstackFeatures(
                 output_field=FieldName.FEAT_DYNAMIC_REAL,
                 input_fields=[FieldName.FEAT_TIME],
             ),
             transform.SetFieldIfNotPresent(
                 field=FieldName.FEAT_STATIC_CAT, value=[0.0]
             ),
             transform.AsNumpyArray(
                 field=FieldName.FEAT_STATIC_CAT, expected_ndim=1
             ),
         ]
     )