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

Register new media transformations automatically #1320

Merged
merged 3 commits into from
Dec 28, 2024

Conversation

wd60622
Copy link
Contributor

@wd60622 wd60622 commented Dec 28, 2024

Description

Adstock and Saturation Transformations will be registry automatically when the class is created (not instantiated). This will allow for a more seamless experience when using the transformations in the future.

from pymc_marketing.mmm import SaturationTransformation

# This registers the class with other saturation transformations
class Identity(SaturationTransformation):
    lookup_name: str = "identity"

    def function(self, x): 
        return x

    default_priors = {}

That makes the class available for serialization and deserialization (i.e. what is done in MMM load method)

from pymc_marketing.deserialize import deserialize

data = {"lookup_name": "identity"}
saturation_transformation = deserialize(data)

assert isinstance(saturation_transformation, Identity)

Related Issue

Checklist

Modules affected

  • MMM
  • CLV

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc-marketing--1320.org.readthedocs.build/en/1320/

@wd60622 wd60622 linked an issue Dec 28, 2024 that may be closed by this pull request
@github-actions github-actions bot added MMM tests enhancement New feature or request labels Dec 28, 2024
@wd60622 wd60622 requested a review from juanitorduz December 28, 2024 00:26
Copy link

codecov bot commented Dec 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.11%. Comparing base (1630589) to head (640d4df).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1320   +/-   ##
=======================================
  Coverage   95.10%   95.11%           
=======================================
  Files          44       44           
  Lines        4703     4725   +22     
=======================================
+ Hits         4473     4494   +21     
- Misses        230      231    +1     

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

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.

Very cool @wd60622 I am learning new cool tricks reviewing these PRs :)

@juanitorduz juanitorduz merged commit 327ac97 into main Dec 28, 2024
19 of 20 checks passed
@juanitorduz juanitorduz deleted the 1319-register-new-transformation-automatically branch December 28, 2024 06:38
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.

Register new transformation automatically
2 participants