Skip to content

excluded _prior suffix from CLV models #1498

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

Merged

Conversation

arthurmello
Copy link
Contributor

@arthurmello arthurmello commented Feb 13, 2025

Description

Removed the _prior suffix from parameters of CLV model config + adjacent files (tests, notebooks, etc.)

Related Issue

Checklist


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

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added docs Improvements or additions to documentation CLV tests good second issue Bit more involved but still doable for newcomers maintenance major API breaking changes model config labels Feb 13, 2025
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.76%. Comparing base (b8b7b9d) to head (cd87a0a).
Report is 91 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1498      +/-   ##
==========================================
+ Coverage   92.75%   92.76%   +0.01%     
==========================================
  Files          52       52              
  Lines        6127     6138      +11     
==========================================
+ Hits         5683     5694      +11     
  Misses        444      444              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@williambdean williambdean left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for the PR @arthurmello

We should provide a deprecation for this. Likely in the clv/basic class. Maybe we can check for any model_config keys with "_prior" suffix then remove while having a warning

Copy link
Contributor

@williambdean williambdean left a comment

Choose a reason for hiding this comment

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

Can we write a test to make sure that save / load is backwards compatible in this scenario

@arthurmello
Copy link
Contributor Author

Sure, do you mean a test that ensures that models saved with the old configuration can still be loaded?
Something like:

def test_backward_compatibility_with_old_config(self, mocker):
        old_model_config = {
            "alpha_prior": ...
            "r_prior": ...
        }
        model = CLVModelTest(model_config=old_model_config)

        mocker.patch("pymc.sample", mock_sample)
        model.fit(...)
        model.save("old_model_config_test")

        loaded_model = CLVModelTest.load("old_model_config_test")

        assert loaded_model.model_config == {
            "alpha": ...,
            "r": ...
        }

@williambdean
Copy link
Contributor

williambdean commented Feb 14, 2025

Yeah, something like that. Dont need to sample. Just load and make sure that a method that uses the posterior still works

We have an issue if the built model has variables without the prefix and posterior samples do have the prefix.

We might have to rename the variables upon load as well

Comment on lines 238 to 243
def test_backward_compatibility_with_old_config(self):
old_model_config = {
"alpha_prior": Prior("Weibull", alpha=2, beta=10),
"r_prior": Prior("Weibull", alpha=2, beta=1),
}
model = CLVModelTest(model_config=old_model_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's test that there is a warning

}
model = CLVModelTest(model_config=old_model_config)
model.fit(tune=0, chains=2, draws=5)
model.save("old_model_config_test")
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't testing for loading from an old saved model. The idata.posterior will have the suffix. We want to check for that suffix in the posterior will not break using the model in the future

@williambdean
Copy link
Contributor

pre-commit.ci autofix

Copy link
Contributor

@williambdean williambdean left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for the PR!

@ColtAllen Can you take a look as well

@williambdean williambdean added this to the 0.12.0 milestone Feb 20, 2025
@ColtAllen
Copy link
Collaborator

Looks good to me. Thanks for the PR!

@ColtAllen Can you take a look as well

I've started looking at this; will post my review tomorrow.

Copy link
Collaborator

@ColtAllen ColtAllen left a comment

Choose a reason for hiding this comment

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

Looks good; just some suggestions to update a unit test and add some removal reminders in addition to @wd60622's requested changes.

Copy link
Collaborator

@ColtAllen ColtAllen left a comment

Choose a reason for hiding this comment

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

Thanks for creating the issue for follow-up work!

@ColtAllen ColtAllen merged commit e00ee1e into pymc-labs:main Feb 23, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLV docs Improvements or additions to documentation good second issue Bit more involved but still doable for newcomers maintenance major API breaking changes model config tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclude prior suffix from CLV model config
3 participants