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

fix(fbprophet): Fix weekly frequencies #20326

Merged
merged 1 commit into from
Jun 20, 2022

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Jun 9, 2022

SUMMARY

The fbprophet packages uses pandas.date_range per here for defining the forecast window where the frequency is defined via an offset alias.

Previously the mapping was wrong, i.e., these weeks which use different days of the weeks as anchors (alongside the direction of the anchor, i.e., starting vs. ending) previously all mapped to W which is the same as W-SUN and thus weekly forecasts did not adhere to the correct periodicity defined in the fitted data.

The fix is merely to use the anchored offsets. Pandas doesn't do a great job in specifying whether it's the week starting or week ending on Sunday say for W-SUN, however it's irrelevant for our needs, i.e., for both "Week starting Sunday" and "Week ending Sunday" the data provided by Superset to fbprohet has been bucketed appropriately and anchored on a Sunday and thus all fbprohet needs to know is Sundays (W-SUN) defines the weekly periodicity.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Tested locally and updated unit tests.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #20326 (34043c4) into master (fd12987) will increase coverage by 0.36%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #20326      +/-   ##
==========================================
+ Coverage   66.56%   66.92%   +0.36%     
==========================================
  Files        1738     1738              
  Lines       65025    65597     +572     
  Branches     6883     6883              
==========================================
+ Hits        43281    43902     +621     
+ Misses      19994    19945      -49     
  Partials     1750     1750              
Flag Coverage Δ
hive 54.20% <ø> (?)
javascript 51.64% <ø> (ø)
mysql 82.51% <ø> (+0.22%) ⬆️
postgres 82.58% <ø> (+0.22%) ⬆️
presto 54.08% <ø> (+0.51%) ⬆️
python 83.02% <ø> (+0.46%) ⬆️
sqlite 82.32% <ø> (+0.23%) ⬆️
unit 50.32% <ø> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/utils/pandas_postprocessing/utils.py 96.55% <ø> (ø)
superset/connectors/sqla/utils.py 90.62% <0.00%> (-0.63%) ⬇️
superset/utils/core.py 90.14% <0.00%> (+0.11%) ⬆️
superset/db_engine_specs/base.py 88.42% <0.00%> (+0.33%) ⬆️
superset/db_engine_specs/databricks.py 92.30% <0.00%> (+1.39%) ⬆️
superset/datasets/api.py 90.49% <0.00%> (+1.96%) ⬆️
superset/connectors/sqla/models.py 92.21% <0.00%> (+2.16%) ⬆️
superset/db_engine_specs/hive.py 85.87% <0.00%> (+15.64%) ⬆️
superset/db_engines/hive.py 85.18% <0.00%> (+85.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd12987...34043c4. Read the comment docs.

@john-bodley john-bodley changed the title [fbprophet] Fix frequencies fix(fbprophet): Fix weekly frequencies Jun 9, 2022
@john-bodley john-bodley force-pushed the john-bodley--fb-prophet-fix-frequencies branch from 0592604 to 34043c4 Compare June 14, 2022 19:32
@john-bodley
Copy link
Member Author

@zhaoyongjie would you mind reviewing this PR?

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

Tested in my local, goods great. Thanks for the fix. I believed that the master branch code coverage was 100%, and you can safely merge this.

@john-bodley john-bodley merged commit 8b0bee5 into master Jun 20, 2022
@john-bodley john-bodley deleted the john-bodley--fb-prophet-fix-frequencies branch June 20, 2022 04:53
michael-s-molina pushed a commit that referenced this pull request Jun 23, 2022
@mistercrunch mistercrunch added 🍒 2.0.0 🍒 2.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v2.0 🍒 2.0.0 🍒 2.0.1 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants