Back to models
Transformer

PeakTimeFeature

PeakTime feature extraction for use in e.g. tree based models.

Quickstart

python
from sktime.transformations.peak import PeakTimeFeature

estimator = PeakTimeFeature(ts_freq=None, peak_hour_start=None, peak_hour_end=None, peak_day_start=None, peak_day_end=None, peak_week_start=None, peak_week_end=None, peak_month_start=None, peak_month_end=None, peak_quarter_start=None, peak_quarter_end=None, peak_year_start=None, peak_year_end=None, working_hour_start=None, working_hour_end=None, keep_original_columns=False, keep_original_peaktime_data_columns=False)

Parameters(17)

ts_freqstr, default= None
Restricts selection of items to those with a frequency lower than the frequency of the time series given by ts_freq. E.g., if daily data is provided and ts_freq = (“D”), it does not make sense to derive PeakTimeFeature with higher frequency like hourly features. So, the outpul must exclude is_peak_hour and will be is_peak_day, is_peak_week, is_peak_month, is_peak_quarter, is_peak_year. Only supports the following frequencies: {“Y”: year, “Q”: quarter, “M”: month, “W”: week, “D”: day, “H”: hour}
peak_hour_startlist, default= None
start interval of peak hour(s) in a list where the first argument determines the first start hour, the second one determines the second start hour and so on. [peak_hour_start1, peak_hour_start2, peak_hour_start3, …]
peak_hour_endlist, default= None
end interval of peak hour(s) in a list where the first argument determines the first end hour, the second one determines the second end hour and so on. [peak_hour_end1, peak_hour_end2, peak_hour_end3, …]
peak_day_startlist, default= None
start interval of peak day(s) in a list where the first argument determines the first start day, the second one determines the second start day and so on. [peak_day_start1, peak_day_start2, peak_day_start3, …]
peak_day_endlist, default= None
end interval of peak day(s) in a list where the first argument determines the first end day, the second one determines the second end day and so on. [peak_day_end1, peak_day_end2, peak_day_end3, …]
peak_week_startlist, default= None
start interval of peak week(s) in a list where the first argument determines the first start week, the second one determines the second start week and so on. [peak_week_start1, peak_week_start2, peak_week_start3, …]
peak_week_endlist, default= None
end interval of peak week(s) in a list where the first argument determines the first end week, the second one determines the second end week and so on. [peak_week_end1, peak_week_end2, peak_week_end3, …]
peak_month_startlist, default= None
start interval of peak month(s) in a list where the first argument determines the first start month, the second one determines the second start month and so on. [peak_month_start1, peak_month_start2, peak_month_start3, …]
peak_month_endlist, default= None
end interval of peak month(s) in a list where the first argument determines the first end month, the second one determines the second end month and so on. [peak_month_end1, peak_month_end2, peak_month_end3, …]
peak_quarter_startlist, default= None
start interval of peak quarter(s) in a list where the first argument determines first start quarter, the second one determines the second start quarter and so on. [peak_quarter_start1, peak_quarter_start2, peak_quarter_start3, …]
peak_quarter_endlist, default= None
end interval of peak quarter(s) in a list where the first argument determines first end quarter, the second one determines the second end quarter and so on. [peak_quarter_end1, peak_quarter_end2, peak_quarter_end3, …]
peak_year_startlist, default= None
start interval of peak year(s) in a list where the first argument determines first start year, the second one determines the second start year and so on. [peak_year_start1, peak_year_start2, peak_year_start3, …]
peak_year_endlist, default= None
end interval of peak year(s) in a list where the first argument determines first end year, the second one determines the second end year and so on. [peak_year_end1, peak_year_end2, peak_year_end3, …]
working_hour_startlist, default= None
start interval of working hour(s) in a list where the first argument determines first start working hour, the second one determines the second start working hour and so on. e.g., [working_hour_start1, working_hour_start2, working_hour_start3, …]
working_hour_endlist, default= None
end interval of working hour(s) in a list where the first argument determines first end working hour, the second one determines the second end working hour and so on. [working_hour_end1, working_hour_end2, working_hour_end3, …]
keep_original_columnsboolean, optional, default=False

If True, keep original columns in main dataframe (X) passed to .transform().

keep_original_peaktime_data_columns: boolean, optional, default=False
If True, keep original peaktime_data dataframe columns including all separate peak/working columns, e.g., peak_hour_1, peak_hour_2, peak_week_1, peak_week_2, …

Examples

>>> from sktime.transformations.peak import PeakTimeFeature
>>> from sktime.datasets import
>>> y = load_solar ()
>>> y = y. tz_localize (None)
>>> y = y. asfreq ("H") Example 1: one interval for peak hour and working hour. (based on one start/end interval) Returns columns is_peak_hour, is_working_hour
>>> transformer = PeakTimeFeature (ts_freq = "H",
... peak_hour_start = [6 ], peak_hour_end = [9 ],
... working_hour_start = [8 ], working_hour_end = [16 ]
... )
>>> y_hat_peak = transformer. fit_transform (y) Example 2: two intervals for peak hour and working hour. (based on two start/end intervals) Returns columns is_peak_hour, is_working_hour
>>> transformer = PeakTimeFeature (ts_freq = "H",
... peak_hour_start = [6, 16 ], peak_hour_end = [9, 20 ],
... working_hour_start = [8, 15 ], working_hour_end = [12, 19 ]
... )
>>> y_hat_peak = transformer. fit_transform (y) Example 3: We may have peak for different seasonality Here is an example for peak hour, peak day, peak week, peak month for two intervals (based on two start/end intervals) Returns columns is_peak_hour, is_peak_day, is_peak_week, is_peak_month
>>> transformer = PeakTimeFeature (ts_freq = "H",
... peak_hour_start = [6, 16 ], peak_hour_end = [9, 20 ],
... peak_day_start = [1, 2 ], peak_day_end = [2, 3 ],
... peak_week_start = [35, 45 ], peak_week_end = [40, 52 ],
... peak_month_start = [1, 7 ], peak_month_end = [6, 12 ]
... )
>>> y_hat_peak = transformer. fit_transform (y)