Table Of Contents
Table Of Contents

gluonts.time_feature.holiday module

class gluonts.time_feature.holiday.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.holiday.distance_to_holiday(holiday)[source]
gluonts.time_feature.holiday.exponential_kernel(alpha=1.0, tol=1e-09)[source]
gluonts.time_feature.holiday.indicator(distance)[source]
gluonts.time_feature.holiday.squared_exponential_kernel(alpha=1.0, tol=1e-09)[source]