From 101bd068dd3686a652c29707655416f6e84eb183 Mon Sep 17 00:00:00 2001 From: Navya Zaveri Date: Thu, 25 Apr 2024 14:02:27 -0700 Subject: [PATCH] Parse provided holiday list into a dataframe Summary: Currently, we pass `self.holidays` into `get_holiday_dates` to infer all the holidays that require adjustments to anomaly scores. Unfortunately, `self.holidays` is `None` in predict calls -- it's only [instantiated](https://fburl.com/code/pauwfwhb) when calling `fit()`. In 1D, since we create a new ProphetModel instance when calling `predict()` (with the underlying fbprophet model passed in), `self.holidays` will be None on that recreated instance. Thus, explicitly create a dataframe with the holidays on predict calls. Reviewed By: irumata Differential Revision: D56586165 fbshipit-source-id: df156e7bd6d5ecbbd47674d769f8316788c98c02 --- kats/detectors/prophet_detector.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kats/detectors/prophet_detector.py b/kats/detectors/prophet_detector.py index c99559a00..c9bf0e61a 100644 --- a/kats/detectors/prophet_detector.py +++ b/kats/detectors/prophet_detector.py @@ -590,8 +590,12 @@ def predict( self.holiday_multiplier is not None and round(self.holiday_multiplier, 10) != 1.0 ): + # convert the list of custom holidays into a df + custom_holidays = ( + pd.DataFrame(self.holidays_list) if self.holidays_list else None + ) holidays_df: Optional[pd.Series] = get_holiday_dates( - self.holidays, self.country_holidays, data.time + custom_holidays, self.country_holidays, data.time ) if holidays_df is not None: scores_ts = pd.Series(list(scores.value), index=data.time)