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

add_seasonality does not expose the condition_name parameter for the prophet model #1049

Closed
dagap opened this issue Jun 29, 2022 · 2 comments · Fixed by #1829
Closed

add_seasonality does not expose the condition_name parameter for the prophet model #1049

dagap opened this issue Jun 29, 2022 · 2 comments · Fixed by #1829
Labels
improvement New feature or improvement

Comments

@dagap
Copy link

dagap commented Jun 29, 2022

Is your feature request related to a current problem? Please describe.
The FB prophet add_seasonality method has a condition_name input variable that is not exposed by darts. This severely limits how custom seasonalities can be added.

Describe proposed solution
The add_seasonality method in Prophet class should also take the condition_name as a parameter.

Additionally, the current method which adds the serasonality also ignores the prior_scale and mode parameters.


# prophet_model.py
for seasonality_name, attributes in self._add_seasonalities.items():
            self.model.add_seasonality(
                name=seasonality_name,
                period=attributes["seasonal_periods"] * interval_length,
                fourier_order=attributes["fourier_order"],
            )
# does not pass the mode, prior_scale and the condition_name parameters
@dagap dagap added the triage Issue waiting for triaging label Jun 29, 2022
@hrzn hrzn added improvement New feature or improvement and removed triage Issue waiting for triaging labels Jul 4, 2022
@hrzn
Copy link
Contributor

hrzn commented Jul 4, 2022

Thanks for this suggestion. Would you be willing to make a contribution in this direction?

@dagap
Copy link
Author

dagap commented Jul 4, 2022

More than happy! However, there are a few things that would need to change, and perhaps if you could suggest a direction. So another thing in the code that is an issue is:

fit_df = pd.DataFrame(
            data={"ds": series.time_index, "y": series.univariate_values()}
        )

Do you think we should add these extra columns as covariates? The reason I am hesitating is that some of these condition columns are not necessarily covariates.

Currently, I am hacking it as:

training_df = series.pd_dataframe(copy=False)
data_df = {"ds": training_df.index}

for col in training_df.columns.values:
    data_df[col] = training_df[col].values

but perhaps this is not ideal? The predict bits would also need to change to allow creating the correct df.

id5h pushed a commit to id5h/darts that referenced this issue Jun 13, 2023
dennisbader added a commit that referenced this issue Jul 18, 2023
…_seasonality (#1829)

* Fix #1049 - add prior_scale and mode arguments to prophet model's add_seasonality

* Add option to treat seasonality as conditional

* Add seasonality conditions with a condition_name and future_covariates

* Add test for custom conditional seasonality

* Add entry for pr #1829

* Update darts/models/forecasting/prophet_model.py

Co-authored-by: Dennis Bader <[email protected]>

* Update darts/models/forecasting/prophet_model.py

Co-authored-by: Dennis Bader <[email protected]>

* Validate seasonality considitions through a private method when calling fit() and predict()

* Reduce predict horizon to 7. Add tests for missing and invalid conditions

* Move entry to models improvements section

* Update err msg in _check_seasonality_conditions

Co-authored-by: Dennis Bader <[email protected]>

* Import raise_log. Initialize formatted str when necessary.

* Accept float seasonalities as well. Update test

* Fix dtype of seasonal_periods. Update docstrings.

* update docstring

---------

Co-authored-by: Idan Shilon <[email protected]>
Co-authored-by: Dennis Bader <[email protected]>
@github-project-automation github-project-automation bot moved this to Released in darts Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement New feature or improvement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants