-
Notifications
You must be signed in to change notification settings - Fork 197
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
Media transformation class and different transformations based on subsets of channels #968
Media transformation class and different transformations based on subsets of channels #968
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #968 +/- ##
==========================================
- Coverage 95.62% 95.48% -0.14%
==========================================
Files 36 37 +1
Lines 3517 3590 +73
==========================================
+ Hits 3363 3428 +65
- Misses 154 162 +8 ☔ View full report in Codecov by Sentry. |
pymc_marketing/mmm/__init__.py
Outdated
MediaConfig, | ||
MediaConfigs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we have more different names? Just as "s" at the end is a typo-rick hehe. For example MediaConfig
and MediaConfigList
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 😆
] | ||
|
||
|
||
Apply the media transformation to media data in PyMC model: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this configuration specification be used through the media_config
parameter with the MMM
model class? If so, could you provide an example here as well 🙏 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't a media_config
parameter at the moment. But we could make one 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Super Cool! Just left some questions.
MediaConfigs = list[MediaConfig] | ||
|
||
|
||
def apply_media_transformation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are wrapped in a class, then it should be pretty easy to make a consistent API with the apply
method.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes!
else (self.saturation, self.adstock) | ||
) | ||
|
||
def __call__(self, x, dim): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use call here instead of an apply
method used in individual transformations. WYDT?
As mentioned below, we can have
media_data = ...
online_media_transformation = MediaTransformation(adstock=..., saturation=..., ...)
offline_media_transformation = MediaTransformation(adstock=..., saturation=..., ...)
media_configs = [MediaConfig(media_transformation=online_media_transformation), MediaConfig(media_transformation=offline_media_transformation)]
# Wrapper around current MediaConfigs
comb_media_transformation = CombinedMediaTransformation(media_configs=media_configs)
# Make all three work the same
offline_media_transformation(media_data, dims="media")
online_media_transformation(media_data, dims="media")
comb_media_transformation(media_data, dims="media")
This would have have many conveniences
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 😎
I've addressed all the feedback @juanitorduz except for the integration with For instance, media_transformation = MediaTransformation(...)
mmm = MMM(media_transformation=media_transformation, ...)
media_transformation = MediaConfigList(...)
mmm = MMM(media_transformation=media_transformation, ...) That has some implications:
Definitely doable though Do you want to do now or wait on this? Let me know how you imagine this being added in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay! We should work on iterstions so let's merge this one and leave the MMM integration for another PR (can you please create an issue so that we keep track?)
…ifferent-channels
Yes, will make some issues now. Would you like me to increase the test coverage? |
@wd60622 from my side it looks ok! If you wanna test edge cases go for it. |
I will create an issue for it |
Description
Allow for media transformation on subset of channels
Related Issue
Checklist
Modules affected
Type of change
📚 Documentation preview 📚: https://pymc-marketing--968.org.readthedocs.build/en/968/