Skip to content

Commit 18fe266

Browse files
authored
Add config options to Prophet (Issue #23). (#43)
1 parent 8b8eba7 commit 18fe266

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

merlion/models/forecast/prophet.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def __init__(
2929
weekly_seasonality: Union[bool, int] = "auto",
3030
daily_seasonality: Union[bool, int] = "auto",
3131
add_seasonality="auto",
32+
seasonality_mode="additive",
33+
holidays=None,
3234
uncertainty_samples: int = 100,
3335
**kwargs,
3436
):
@@ -53,7 +55,14 @@ def __init__(
5355
deactivated otherwise. If int, this is the number of Fourier series
5456
components used to model the seasonality (default = 4).
5557
:param add_seasonality: 'auto' indicates automatically adding extra
56-
seasonaltiy by detection methods (default = None).
58+
seasonality by detection methods (default = None).
59+
:param seasonality_mode: 'additive' (default) or 'multiplicative'.
60+
:param holidays: pd.DataFrame with columns holiday (string) and ds (date type)
61+
and optionally columns lower_window and upper_window which specify a
62+
range of days around the date to be included as holidays.
63+
lower_window=-2 will include 2 days prior to the date as holidays. Also
64+
optionally can have a column prior_scale specifying the prior scale for
65+
that holiday.
5766
:param uncertainty_samples: The number of posterior samples to draw in
5867
order to calibrate the anomaly scores.
5968
"""
@@ -62,7 +71,9 @@ def __init__(
6271
self.weekly_seasonality = weekly_seasonality
6372
self.daily_seasonality = daily_seasonality
6473
self.add_seasonality = add_seasonality
74+
self.seasonality_mode = seasonality_mode
6575
self.uncertainty_samples = uncertainty_samples
76+
self.holidays = holidays
6677

6778

6879
class Prophet(ForecasterBase):
@@ -79,7 +90,9 @@ def __init__(self, config: ProphetConfig):
7990
yearly_seasonality=self.yearly_seasonality,
8091
weekly_seasonality=self.weekly_seasonality,
8192
daily_seasonality=self.daily_seasonality,
93+
seasonality_mode=self.seasonality_mode,
8294
uncertainty_samples=self.uncertainty_samples,
95+
holidays=self.holidays,
8396
)
8497
self.last_forecast_time_stamps_full = None
8598
self.last_forecast_time_stamps = None
@@ -111,6 +124,14 @@ def daily_seasonality(self):
111124
def add_seasonality(self):
112125
return self.config.add_seasonality
113126

127+
@property
128+
def seasonality_mode(self):
129+
return self.config.seasonality_mode
130+
131+
@property
132+
def holidays(self):
133+
return self.config.holidays
134+
114135
@property
115136
def uncertainty_samples(self):
116137
return self.config.uncertainty_samples

0 commit comments

Comments
 (0)