Skip to content

Commit

Permalink
fix: floor and cap are now available as extra regressor in prophet te…
Browse files Browse the repository at this point in the history
…mplate. See linkedin#21
  • Loading branch information
samuelefiorini committed Jun 14, 2023
1 parent ec43a9e commit 59f3196
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion greykite/sklearn/estimator/prophet_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ def __init__(
self.model = None
# set by the predict method
self.forecast = None
# Prophet reserved columns
self.reserved_names = [
'trend', 'additive_terms', 'daily', 'weekly', 'yearly',
'holidays', 'zeros', 'extra_regressors_additive', 'yhat',
'extra_regressors_multiplicative', 'multiplicative_terms',
'cap', 'floor'
]

def fit(self, X, y=None, time_col=TIME_COL, value_col=VALUE_COL, **fit_params):
"""Fits prophet model.
Expand Down Expand Up @@ -242,7 +249,8 @@ def fit(self, X, y=None, time_col=TIME_COL, value_col=VALUE_COL, **fit_params):
# This implementation assumes that the regressor(s) are provided in time series df, alongside target column.
if self.add_regressor_dict is not None:
for reg_col, reg_params in self.add_regressor_dict.items():
self.model.add_regressor(name=reg_col, **reg_params)
if reg_col not in self.reserved_names:
self.model.add_regressor(name=reg_col, **reg_params)

# if custom seasonality is provided, we supply it to Prophet model
if self.add_seasonality_dict is not None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@
test_suite="tests",
tests_require=test_requirements,
url="https://github.com/linkedin/greykite",
version="0.5.0",
version="0.5.0.dev1",
zip_safe=False,
)

0 comments on commit 59f3196

Please sign in to comment.