def seasonal_features(cls, freq: str) -> List[TimeFeature]: offset = to_offset(freq) if offset.name == "M": return [MonthOfYearIndex()] elif offset.name == "W-SUN": return [WeekOfYearIndex()] elif offset.name == "D": return [DayOfWeekIndex()] elif offset.name == "B": # TODO: check this case return [DayOfWeekIndex()] elif offset.name == "H": return [HourOfDayIndex(), DayOfWeekIndex()] elif offset.name == "T": return [ MinuteOfHourIndex(), HourOfDayIndex(), ] else: RuntimeError(f"Unsupported frequency {offset.name}") return []
DayOfWeekIndex(), pd.date_range("01-01-2015", periods=365 * 5, freq="D"), 7, ), ( DayOfMonthIndex(), pd.date_range("01-01-2015", periods=365 * 5, freq="D"), 31, ), ( DayOfYearIndex(), pd.date_range("01-01-2015", periods=365 * 5, freq="D"), 366, ), ( WeekOfYearIndex(), pd.date_range("01-01-2015", periods=53 * 5, freq="W"), 53, ), ( MonthOfYearIndex(), pd.date_range("01-01-2015", periods=12 * 5, freq="M"), 12, ), ], ) def test_feature_unnormalized_bounds(feature: TimeFeature, index: pd.DatetimeIndex, cardinality: int): values = feature(index) assert isinstance(values, np.ndarray)
def WeekOfYearSeasonalISSM(): return SeasonalityISSM(num_seasons=53, time_feature=WeekOfYearIndex())