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

Improve usability for conditional seasonality #1116

Merged
merged 21 commits into from
Feb 9, 2023
Merged

Conversation

judussoari
Copy link
Collaborator

@judussoari judussoari commented Jan 15, 2023

🔮 Key changes

Extends #1067
Added docstring example, a new tutorial notebook for conditional seasonality, as well as some validation for float values between 0..1 in the conditional seasonality column.
Also, added helper function to integrate four seasons and/or weekday/weekend conditions. Fixes #609

📋 Review Checklist

  • I have performed a self-review of my own code.
  • I have commented my code, added docstrings and data types to function definitions.
  • I have added pytests to check whether my feature / fix works.

* Quarterly changing weekly seasonality
* On-season and off-season football

* Adapted from Facebook Prophet
@judussoari judussoari added type:docs Improvements or additions to documentation status: needs review PR needs to be reviewed by Reviewer(s) labels Jan 15, 2023
@judussoari judussoari added this to the Release 0.5.2 milestone Jan 15, 2023
@judussoari judussoari self-assigned this Jan 15, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2023

Codecov Report

Merging #1116 (3984f3d) into main (cd75f99) will increase coverage by 0.01%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #1116      +/-   ##
==========================================
+ Coverage   90.16%   90.17%   +0.01%     
==========================================
  Files          36       36              
  Lines        5042     5059      +17     
==========================================
+ Hits         4546     4562      +16     
- Misses        496      497       +1     
Impacted Files Coverage Δ
neuralprophet/df_utils.py 94.52% <100.00%> (-0.06%) ⬇️
neuralprophet/forecaster.py 87.97% <100.00%> (+0.06%) ⬆️
neuralprophet/time_dataset.py 95.53% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@judussoari judussoari changed the title Documentation for conditional seasonality Improve usability for conditional seasonality Jan 15, 2023
@judussoari judussoari added status: blocked and removed status: needs review PR needs to be reviewed by Reviewer(s) labels Jan 17, 2023
@github-actions
Copy link

github-actions bot commented Jan 24, 2023

Model Benchmark

Benchmark Metric main current diff
PeytonManning MAE_val 0.64636 0.64636 0.0%
PeytonManning RMSE_val 0.79276 0.79276 0.0%
PeytonManning Loss_val 0.01494 0.01494 0.0%
PeytonManning MAE 0.42701 0.42701 0.0%
PeytonManning RMSE 0.57032 0.57032 0.0%
PeytonManning Loss 0.00635 0.00635 0.0%
PeytonManning time 11.7219 11.49 -1.98%
YosemiteTemps MAE_val 1.72949 1.72949 0.0%
YosemiteTemps RMSE_val 2.27386 2.27386 0.0%
YosemiteTemps Loss_val 0.00096 0.00096 0.0%
YosemiteTemps MAE 1.45189 1.45189 0.0%
YosemiteTemps RMSE 2.16631 2.16631 0.0%
YosemiteTemps Loss 0.00066 0.00066 0.0%
YosemiteTemps time 96.2555 90.67 -5.8% 🎉
AirPassengers MAE_val 15.4077 15.4077 0.0%
AirPassengers RMSE_val 19.5099 19.5099 0.0%
AirPassengers Loss_val 0.00196 0.00196 0.0%
AirPassengers MAE 9.86947 9.86947 0.0%
AirPassengers RMSE 11.7222 11.7222 0.0%
AirPassengers Loss 0.00057 0.00057 0.0%
AirPassengers time 4.2882 4.04 -5.79% 🎉
Model training plots

Model Training

PeytonManning

YosemiteTemps

AirPassengers

@judussoari judussoari added status: needs review PR needs to be reviewed by Reviewer(s) and removed status: blocked type:docs Improvements or additions to documentation labels Jan 24, 2023
@judussoari
Copy link
Collaborator Author

@ourownstory when you or someone else review this, please have a look at the new helper function with the pre-implmented conditional seasonalities, and evaluate whether it makes sense

* when missing dates are added

* when predicting (ffill at end)
* when missing dates are added

* when predicting (ffill at end)
* when missing dates are added

* when predicting (ffill at end)
* when missing dates are added

* when predicting (ffill at end)
* when missing dates are added

* when predicting (ffill at end)
Copy link
Owner

@ourownstory ourownstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

RE:tutorial:

  • mention helper functions
  • explain what a condition is/must be
  • plot_params: just plot Seasonalities

neuralprophet/df_utils.py Outdated Show resolved Hide resolved
neuralprophet/df_utils.py Outdated Show resolved Hide resolved
--------
Adding a quarterly changing weekly seasonality to the model. First, add columns to df.
The columns should contain only zeros and ones (or floats), deciding when to apply seasonality.
>>> df["summer_week"] = df["ds"].apply(lambda x: x.month in [6, 7, 8])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"summer_week", can drop week

neuralprophet/forecaster.py Outdated Show resolved Hide resolved
@judussoari judussoari added status: ready PR is ready to be merged and removed status: needs review PR needs to be reviewed by Reviewer(s) labels Feb 9, 2023
Copy link
Collaborator

@karl-richter karl-richter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@judussoari judussoari merged commit 05198ba into main Feb 9, 2023
@judussoari judussoari deleted the examples_cond_seas branch February 9, 2023 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready PR is ready to be merged
Projects
None yet
4 participants