gluonts.time_feature package¶
-
class
gluonts.time_feature.
TimeFeature
[source]¶ Bases:
object
Base class for features that only depend on time.
-
class
gluonts.time_feature.
DayOfMonth
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Day of month encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
DayOfWeek
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Hour of day encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
DayOfYear
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Day of year encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
HourOfDay
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Hour of day encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
MinuteOfHour
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Minute of hour encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
MonthOfYear
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Month of year encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
WeekOfYear
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Week of year encoded as value between [-0.5, 0.5]
-
class
gluonts.time_feature.
DayOfMonthIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Day of month encoded as zero-based index, between 0 and 11
-
class
gluonts.time_feature.
DayOfWeekIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Hour of day encoded as zero-based index, between 0 and 6
-
class
gluonts.time_feature.
DayOfYearIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Day of year encoded as zero-based index, between 0 and 365
-
class
gluonts.time_feature.
HourOfDayIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Hour of day encoded as zero-based index, between 0 and 23
-
class
gluonts.time_feature.
MinuteOfHourIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Minute of hour encoded as zero-based index, between 0 and 59
-
class
gluonts.time_feature.
MonthOfYearIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Month of year encoded as zero-based index, between 0 and 11
-
class
gluonts.time_feature.
WeekOfYearIndex
[source]¶ Bases:
gluonts.time_feature._base.TimeFeature
Week of year encoded as zero-based index, between 0 and 52
-
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_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
-
gluonts.time_feature.
time_features_from_frequency_str
(freq_str: str) → List[gluonts.time_feature._base.TimeFeature][source]¶ Returns a list of time features that will be appropriate for the given frequency string.
- Parameters
freq_str – Frequency string of the form [multiple][granularity] such as “12H”, “5min”, “1D” etc.