paddlets.transform.time_feature

class TimeFeatureGenerator(feature_cols: Optional[List[str]] = ['year', 'month', 'day', 'weekday', 'hour', 'quarter', 'dayofyear', 'weekofyear', 'is_holiday', 'is_workday'], extend_points: int = 0)[源代码]

基类:BaseTransform

时间格式数据转换为具体的索引特征

参数
  • feature_cols (str) – 需要提供生成的时间索引特征,可生成的内容:年(year), 月(month), 日(day), 星期(weekday), 小时(hour), 四季(quarter), 当年天数(dayofyear), 当年周数(weekofyear), 节假日(is_holiday), 工作日(is_workday)。默认全部生成。

  • extend_points (int) – 需要在已存在的target时序数据尾部拼接的额外的时间点。仅当以下2个情况同时满足时,该参数会被用到:第一,未来已知的协变量(known covariates) 为None,并且当前调用的是 predict() 方法。 拼接这段额外的时间点的原因是 predict 方法需要获取待预测的未来(future)target时序数据的尾部索引,通常来说该索引可以通过未来已知的协变量(known covariates)计算得到,但是,如果其为None,则未来(future)target的尾部索引需要在当前transform中被手动拼接在存量的target后面,才能在 predict() 调用中提供未来(future)target的尾部索引的信息。

返回

None

fit(dataset: TSDataset)[源代码]

当前transformer不需要被训练。

参数

dataset (TSDataset) – 需要进行拟合的数据

返回

TimeFeatureGenerator

transform(dataset: TSDataset, inplace: bool = False) TSDataset[源代码]

转换时间索引到时间类型特征

参数
  • dataset (TSDataset) – 需要进行转换的数据

  • inplace (bool) – 是否对数据原地转换。如果为False则对数据副本进行转换, 不修改原数据。默认为False。

返回

时序数据集

fit_transform(dataset: TSDataset, inplace: bool = False) TSDataset[源代码]

时间索引转换到时间类型特征

参数
  • dataset (TSDataset) – 需要进行拟合和转换的数据

  • inplace (bool) – 是否对数据原地转换。如果为False则对数据副本进行转换, 不修改原数据。默认为False。

返回

时序数据集