Skip to content

Commit

Permalink
Parse provided holiday list into a dataframe
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Navya Zaveri authored and facebook-github-bot committed Apr 25, 2024
1 parent 192d172 commit 101bd06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kats/detectors/prophet_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 101bd06

Please sign in to comment.