gluonts.time_feature 包#

class gluonts.time_feature.Constant(*, value: float = 0.0)[source]#

基类: pydantic.v1.main.BaseModel

使用预定义值的常数时间特征。

value: float#
class gluonts.time_feature.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]])
gluonts.time_feature.day_of_month(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的月份中的日期

gluonts.time_feature.day_of_month_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 11 的零基索引的月份中的日期。

gluonts.time_feature.day_of_week(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的星期几

gluonts.time_feature.day_of_week_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 6 的零基索引的星期几。

gluonts.time_feature.day_of_year(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的年份中的日期

gluonts.time_feature.day_of_year_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 365 的零基索引的年份中的日期。

gluonts.time_feature.get_lags_for_frequency(freq_str: str, lag_ub: int = 1200, num_lags: Optional[int] = None, num_default_lags: int =7) List[int][source]#

生成适用于给定频率字符串的滞后列表。

默认情况下,所有频率都具有以下滞后:[1, 2, 3, 4, 5, 6, 7]。剩余滞后对应于先前 k 个周期中的同一 season (+/- delta)。这里的 deltak 根据现有代码选择。

参数
  • freq_str – 频率字符串,形式为 [倍数][粒度],例如 “12H”、“5min”、“1D” 等。

  • lag_ub – 滞后的最大值。

  • num_lags – 最大滞后数;默认返回所有生成的滞后。

  • num_default_lags – 默认滞后数;默认值为 7。

gluonts.time_feature.get_seasonality(freq: str, seasonalities={'B': 5, 'D': 1, 'H': 24, 'M': 12, 'ME': 12, 'Q': 4, 'QE': 4, 'S': 3600, 'T': 1440, 'W': 1, 'h': 24, 'min': 1440, 's': 3600}) int[source]#

返回给定频率的季节性

>>> get_seasonality("2h")
12
gluonts.time_feature.hour_of_day(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的一天中的小时

gluonts.time_feature.hour_of_day_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 23 的零基索引的一天中的小时。

gluonts.time_feature.minute_of_hour(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的小时中的分钟

gluonts.time_feature.minute_of_hour_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 59 的零基索引的小时中的分钟。

gluonts.time_feature.month_of_year(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的年份中的月份

gluonts.time_feature.month_of_year_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 11 的零基索引的年份中的月份。

gluonts.time_feature.norm_freq_str(freq_str: str) str[source]#
gluonts.time_feature.second_of_minute(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[源代码]#

编码为 [-0.5, 0.5] 之间值的分钟中的秒

gluonts.time_feature.second_of_minute_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 59 的零基索引的分钟中的秒。

gluonts.time_feature.time_features_from_frequency_str(freq_str: str) List[Callable[[pandas.core.indexes.period.PeriodIndex], numpy.ndarray]][source]#

返回适用于给定频率字符串的时间特征列表。

参数

freq_str – 频率字符串,形式为 [倍数][粒度],例如 “12H”、“5min”、“1D” 等。

gluonts.time_feature.week_of_year(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为 [-0.5, 0.5] 之间值的年份中的周

gluonts.time_feature.week_of_year_index(index: pandas.core.indexes.period.PeriodIndex) numpy.ndarray[source]#

编码为从 0 到 52 的零基索引的年份中的周。