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 basis bumps effect to MMM model #1475

Merged
merged 14 commits into from
Feb 9, 2025
Merged

Add basis bumps effect to MMM model #1475

merged 14 commits into from
Feb 9, 2025

Conversation

wd60622
Copy link
Contributor

@wd60622 wd60622 commented Feb 7, 2025

Description

The API

mmm = MMM(...)

mmm.add_events(df_holidays, prefix="holiday", effect=...)
mmm.add_events(df_weekends, prefix="weekend", effect=...)
mmm.add_events(df_earning_calls, prefix="earning_call", effect=...)
mmm.build_model(X, y)

TODO:

  • Handle out of sample predictions
  • Relax the EventEffect requiring dims / make assumptions since it will be duplicated in the effect

Related Issue

  • Closes #
  • Related to #

Checklist

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 96.38554% with 3 lines in your changes missing coverage. Please review.

Project coverage is 92.59%. Comparing base (eec024d) to head (046bc5d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pymc_marketing/mmm/multidimensional.py 96.22% 2 Missing ⚠️
pymc_marketing/mmm/events.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1475      +/-   ##
==========================================
+ Coverage   92.55%   92.59%   +0.04%     
==========================================
  Files          52       52              
  Lines        5947     6026      +79     
==========================================
+ Hits         5504     5580      +76     
- Misses        443      446       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wd60622 wd60622 requested a review from cetagostini February 7, 2025 14:50
@wd60622 wd60622 added the enhancement New feature or request label Feb 7, 2025
Comment on lines +122 to +126
def create_basis_matrix(s_ref, e_ref):
return pt.where(
(s_ref >= 0) & (e_ref <= 0),
0,
pt.where(pt.abs(s_ref) < pt.abs(e_ref), s_ref, e_ref),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want control over this? @juanitorduz

Copy link
Collaborator

Choose a reason for hiding this comment

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

seems reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reasonable default or would it be passed with Basis? It causes issue if we are trying to keep track of what the user passes though for building the model

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not have a strong opinion so I suggest whatever you feel is easiest to maintain. We can release and collect feedback.

Copy link
Collaborator

@juanitorduz juanitorduz left a comment

Choose a reason for hiding this comment

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

Looks very nice! I left som minor comments.

Are the open to-dos meant to be included in this PR?

Comment on lines +122 to +126
def create_basis_matrix(s_ref, e_ref):
return pt.where(
(s_ref >= 0) & (e_ref <= 0),
0,
pt.where(pt.abs(s_ref) < pt.abs(e_ref), s_ref, e_ref),
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems reasonable

@wd60622
Copy link
Contributor Author

wd60622 commented Feb 7, 2025

Addressed the feedback. I will make the todos into new issues

@wd60622
Copy link
Contributor Author

wd60622 commented Feb 8, 2025

Working on the out of sample now

@wd60622
Copy link
Contributor Author

wd60622 commented Feb 8, 2025

This should be good to go now. I will work toward the storing off of the events in another PR (#1484)

@juanitorduz
Copy link
Collaborator

juanitorduz commented Feb 8, 2025

This is very cool! I'll try to see if I can add this to the mmm example notebook as well have two events.

@wd60622 wd60622 merged commit 23ec02e into main Feb 9, 2025
20 of 21 checks passed
@wd60622 wd60622 deleted the add-events branch February 9, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MMM tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants