Table Of Contents
Table Of Contents

gluonts.time_feature package

class gluonts.time_feature.DayOfMonth(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Day of month encoded as value between [-0.5, 0.5]

class gluonts.time_feature.DayOfWeek(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Hour of day encoded as value between [-0.5, 0.5]

class gluonts.time_feature.DayOfYear(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Day of year encoded as value between [-0.5, 0.5]

class gluonts.time_feature.HourOfDay(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Hour of day encoded as value between [-0.5, 0.5]

class gluonts.time_feature.MinuteOfHour(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Minute of hour encoded as value between [-0.5, 0.5]

class gluonts.time_feature.MonthOfYear(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Month of year encoded as value between [-0.5, 0.5]

class gluonts.time_feature.TimeFeature(normalized: bool = True)[source]

Bases: object

Base class for features that only depend on time.

class gluonts.time_feature.WeekOfYear(normalized: bool = True)[source]

Bases: gluonts.time_feature._base.TimeFeature

Week of year encoded as value between [-0.5, 0.5]

class gluonts.time_feature.SpecialDateFeatureSet(feature_names: List[str], kernel_function: Callable[int, int] = <function indicator>)[source]

Bases: object

Implements calculation of holiday features. The SpecialDateFeatureSet is applied on a pandas Series with Datetimeindex and returns a 2D array of the shape (len(dates), num_features), where num_features are the number of holidays.

Note that for lower than daily granularity the distance to the holiday is still computed on a per-day basis.

Example use:

>>> 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.]])

Example use for using a squared exponential kernel:

>>> 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.get_granularity(freq_str: str) → Tuple[int, str][source]

Splits a frequency string such as “7D” into the multiple 7 and the base granularity “D”.

Parameters:freq_str – Frequency string of the form [multiple][granularity] such as “12H”, “5min”, “1D” etc.
gluonts.time_feature.get_lags_for_frequency(freq_str: str, lag_ub: int = 1200, num_lags: Optional[int] = None) → List[int][source]

Generates a list of lags that that are appropriate for the given frequency string.

By default all frequencies have the following lags: [1, 2, 3, 4, 5, 6, 7]. Remaining lags correspond to the same season (+/- delta) in previous k cycles. Here delta and k are chosen according to the existing code.

Parameters:
  • freq_str – Frequency string of the form [multiple][granularity] such as “12H”, “5min”, “1D” etc.
  • lag_ub – The maximum value for a lag.
  • num_lags – Maximum number of lags; by default all generated lags are returned