DateTimeFeatures
DateTime feature extraction, e.g., for use as exogenous data in forecasting.
Quickstart
from sktime.transformations.date import DateTimeFeatures
estimator = DateTimeFeatures(ts_freq=None, feature_scope='minimal', manual_selection=None, keep_original_columns=False)Parameters(4)
- ts_freqstr, optional (default=”day”)
Frequency of the time series. Restricts selection of items to those with a frequency lower than the frequency of the time series given by ts_freq. E.g. if monthly data is provided and ts_freq = (“M”), it does not make sense to derive dummies with higher frequency like weekly dummies. Has to be provided by the user due to the abundance of different frequencies supported by Pandas (e.g. every pandas allows freq of every 4 days). Interaction with other arguments: Used to narrow down feature selection for feature_scope, since only features with a frequency lower than ts_freq are considered. Will be ignored for the calculation of manually specified features, but when provided will raise a warning if manual features have a frequency higher than ts_freq. Only supports the following frequencies:
Y - year
Q - quarter
M - month
W - week
D - day
H - hour
T - minute
S - second
L - millisecond
- feature_scope: str, optional (default=”minimal”)
Specify how many calendar features you want to be returned. E.g., rarely used features like week of quarter will only be returned with feature_scope = “comprehensive”.
“minimal”
“efficient”
“comprehensive”
- manual_selection: str, optional (default=None)
Manual selection of dummys. Notation is child of parent for precise notation. Will ignore specified feature_scope, but will still check with warning against a specified ts_freq. All columns returned are integer based. Dates are presented in DD-MM-YYYY format below. Supported values:
None
- quarter_of_year
1-based index 1-(Jan to Mar), 2-(Apr to Jun), 3-(Jul to Sep), 4-(Oct to Dec)
- keep_original_columnsboolean, optional, default=False
Keep original columns in X passed to
.transform().
Examples
>>> from sktime.transformations.date import DateTimeFeatures
>>> from sktime.datasets import load_airline
>>> y = load_airline () Returns columns y, year, month_of_year
>>> transformer = DateTimeFeatures (ts_freq = "M")
>>> y_hat = transformer. fit_transform (y) Returns columns y, month_of_year
>>> transformer = DateTimeFeatures (ts_freq = "M", manual_selection = ["month_of_year" ])
>>> y_hat = transformer. fit_transform (y) Returns columns ‘y’, ‘year’, ‘quarter_of_year’, ‘month_of_year’, ‘month_of_quarter’
>>> transformer = DateTimeFeatures (ts_freq = "M", feature_scope = "comprehensive")
>>> y_hat = transformer. fit_transform (y) Returns columns ‘y’, ‘year’, ‘quarter_of_year’, ‘month_of_year’
>>> transformer = DateTimeFeatures (ts_freq = "M", feature_scope = "efficient")
>>> y_hat = transformer. fit_transform (y) Returns columns ‘y’, ‘year’, ‘month_of_year’
>>> transformer = DateTimeFeatures (ts_freq = "M", feature_scope = "minimal")
>>> y_hat = transformer. fit_transform (y)