Transformer
HolidayFeatures
Holiday features extraction.
Quickstart
python
from sktime.transformations.holiday import HolidayFeatures
estimator = HolidayFeatures(calendar: dict [date, str ], holiday_windows: dict [str, tuple ]=None, include_bridge_days: bool=False, include_weekend: bool=False, return_dummies: bool=True, return_categorical: bool=False, return_indicator: bool=False, keep_original_columns: bool=False)Parameters(8)
- calendarHolidayBase object or Dict[date, str]
Calendar object from holidays package [1].
- holiday_windowsDict[str, tuple], default=None
- Dictionary for specifying a window of days around holidays, with keys being holiday names and values being (n_days_before, n_days_after) tuples.
- include_bridge_days: bool, default=False
- If True, include bridge days. Bridge days include Monday if a holiday is on Tuesday and Friday if a holiday is on Thursday.
- include_weekend: bool, default=False
- If True, include weekends as holidays.
- return_dummiesbool, default=True
- Whether or not to return a dummy variable for each holiday.
- return_categoricalbool, default=False
- Whether or not to return a categorical variable with holidays beings categories.
- return_indicatorbool, default=False
- Whether or not to return an indicator variable equal to 1 if a time point is a holiday or not.
- keep_original_columnsbool, default=False
Keep original columns in X passed to
.transform().
Examples
>>> import numpy as np
>>> import pandas as pd
>>> from datetime import date
>>> from holidays import country_holidays, financial_holidays
>>> values = np. random. normal (size = 365)
>>> index = pd. date_range ("2000-01-01", periods = 365, freq = "D")
>>> X = pd. DataFrame (values, index = index) Returns country holiday features with custom holiday windows
>>> from sktime.transformations.holiday import HolidayFeatures
>>> transformer = HolidayFeatures (
... calendar = country_holidays (country = "FR"),
... return_categorical = True,
... holiday_windows = { "Noël": (1, 3), "Jour de l'an": (1, 0)})
>>> yt = transformer. fit_transform (X) Returns financial holiday features
>>> transformer = HolidayFeatures (
... calendar = financial_holidays (market = "NYSE"),
... return_categorical = True,
... include_weekend = True)
>>> yt = transformer. fit_transform (X) Returns custom made holiday features
>>> transformer = HolidayFeatures (
... calendar = { date (2000, 1, 14): "Regional Holiday",
... date (2000, 1, 26): "Regional Holiday" },
... return_categorical = True)
>>> yt = transformer. fit_transform (X)References
- [1 ] https://pypi.org/project/holidays/