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 Censored wrapper for Prior class #1309

Merged
merged 48 commits into from
Dec 25, 2024
Merged

Add Censored wrapper for Prior class #1309

merged 48 commits into from
Dec 25, 2024

Conversation

wd60622
Copy link
Contributor

@wd60622 wd60622 commented Dec 22, 2024

Closes #1238

Related to #1296

from pymc_marketing.prior import Prior, Censored

normal = Prior("Normal", dims=("channel", "geo"))
censored_normal = Censored(normal, lower=0)

With implemented methods:

  • create_variable
  • create_likelihood_variable
  • sample_prior
  • to_graph
  • to_dict
  • from_dict

And support from deserialize function

This allows it to be used in MMM. For example:

from pymc_marketing.mmm import MMM

normal = Prior("Normal", sigma=Prior("HalfNormal"), dims="date")
censored_normal = Censored(normal, lower=0) 

model_config = {"likelihood": censored_normal}

mmm = MMM(
    ...,
    model_config=model_config,
)

CC: @drbenvincent


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

@wd60622 wd60622 force-pushed the censored-distribution branch from b4a7501 to 1e13dc3 Compare December 22, 2024 10:29
Copy link

codecov bot commented Dec 22, 2024

Codecov Report

Attention: Patch coverage is 92.95775% with 5 lines in your changes missing coverage. Please review.

Project coverage is 95.10%. Comparing base (8600ef3) to head (b6a0457).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pymc_marketing/prior.py 92.95% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1309      +/-   ##
==========================================
- Coverage   95.14%   95.10%   -0.04%     
==========================================
  Files          44       44              
  Lines        4633     4703      +70     
==========================================
+ Hits         4408     4473      +65     
- Misses        225      230       +5     

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

@wd60622 wd60622 changed the base branch from main to deserialize December 22, 2024 13:09
Base automatically changed from deserialize to main December 22, 2024 19:23
@github-actions github-actions bot added the enhancement New feature or request label Dec 23, 2024
@wd60622 wd60622 marked this pull request as ready for review December 23, 2024 10:22
@wd60622 wd60622 requested a review from juanitorduz December 23, 2024 10:24
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.

cool! just a suggestion about the class type :)

pymc_marketing/prior.py Show resolved Hide resolved
@wd60622 wd60622 merged commit f4fe828 into main Dec 25, 2024
19 of 20 checks passed
@wd60622 wd60622 deleted the censored-distribution branch December 25, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prior support for censored variables
2 participants