gluonts.time_feature.holiday 模块#
- class gluonts.time_feature.holiday.SpecialDateFeatureSet(feature_names: typing.List[str], kernel_function: typing.Callable[[int], int] = <function indicator>)[source]#
基类:
object
实现节假日特征的计算。SpecialDateFeatureSet 应用于具有 Datetimeindex 的 pandas Series,并返回形状为 (len(dates), num_features) 的二维数组,其中 num_features 是节假日的数量。
请注意,对于低于每日粒度的数据,节假日的距离仍然按天计算。
使用示例
>>> from gluonts.time_feature.holiday import ( ... squared_exponential_kernel, ... SpecialDateFeatureSet, ... CHRISTMAS_DAY, ... CHRISTMAS_EVE ... ) >>> import pandas as pd >>> sfs = SpecialDateFeatureSet([CHRISTMAS_EVE, CHRISTMAS_DAY]) >>> date_indices = pd.date_range( ... start="2016-12-24", ... end="2016-12-31", ... freq='D' ... ) >>> sfs(date_indices) array([[1., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0., 0.]])
使用平方指数核函数的使用示例
>>> kernel = squared_exponential_kernel(alpha=1.0) >>> sfs = SpecialDateFeatureSet([CHRISTMAS_EVE, CHRISTMAS_DAY], kernel) >>> sfs(date_indices) array([[1.00000000e+00, 3.67879441e-01, 1.83156389e-02, 1.23409804e-04, 1.12535175e-07, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [3.67879441e-01, 1.00000000e+00, 3.67879441e-01, 1.83156389e-02, 1.23409804e-04, 1.12535175e-07, 0.00000000e+00, 0.00000000e+00]])