Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Expose seasonality parameters of ProphetPiecewiseLinearTrendForecaster #5834

Merged
merged 11 commits into from Feb 18, 2024
38 changes: 35 additions & 3 deletions sktime/forecasting/trend/_pwl_trend_forecaster.py
Expand Up @@ -4,6 +4,8 @@

__author__ = ["sbuse"]

from warnings import warn

import pandas as pd

from sktime.forecasting.base._base import DEFAULT_ALPHA
Expand Down Expand Up @@ -51,6 +53,18 @@ class ProphetPiecewiseLinearTrendForecaster(_ProphetAdapter):
automatic changepoint selection. Large values will allow many
changepoints, small values will allow few changepoints.
Recommended to take values within [0.001,0.5].
yearly_seasonality: str or bool or int, default="auto"
Include yearly seasonality in the model. "auto" for automatic determination,
True to enable, False to disable, or an integer specifying the number of terms
to include in the Fourier series.
weekly_seasonality: str or bool or int, default="auto"
Include weekly seasonality in the model. "auto" for automatic determination,
True to enable, False to disable, or an integer specifying the number of terms
to include in the Fourier series.
daily_seasonality: str or bool or int, default="auto"
Include weekly seasonality in the model. "auto" for automatic determination,
True to enable, False to disable, or an integer specifying the number of terms
to include in the Fourier series.

References
----------
Expand Down Expand Up @@ -89,6 +103,9 @@ def __init__(
changepoint_range=0.8,
changepoint_prior_scale=0.05,
verbose=0,
yearly_seasonality="auto",
weekly_seasonality="auto",
daily_seasonality="auto",
):
self.freq = None
self.add_seasonality = None
Expand All @@ -99,9 +116,9 @@ def __init__(
self.changepoints = changepoints
self.n_changepoints = n_changepoints
self.changepoint_range = changepoint_range
self.yearly_seasonality = "auto"
self.weekly_seasonality = "auto"
self.daily_seasonality = "auto"
self.yearly_seasonality = yearly_seasonality
self.weekly_seasonality = weekly_seasonality
self.daily_seasonality = daily_seasonality
self.holidays = None
self.seasonality_mode = "additive"
self.seasonality_prior_scale = 10.0
Expand All @@ -115,6 +132,21 @@ def __init__(

super().__init__()

if any(
setting != "auto"
for setting in [
yearly_seasonality,
weekly_seasonality,
daily_seasonality,
]
):
message = (
"Warning: In the release 0.28.0, the default of all seasonality "
"parameters will change to 'False'. Please review your code and "
"update the parameters to prevent any unexpected behavior. "
)
warn(message, FutureWarning, stacklevel=2)

# import inside method to avoid hard dependency
from prophet.forecaster import Prophet as _Prophet

Expand Down