pymc-labs / pymc-marketing

Bayesian marketing toolbox in PyMC. Media Mix (MMM), customer lifetime value (CLV), buy-till-you-die (BTYD) models and more.
https://www.pymc-marketing.io/
Apache License 2.0
663 stars 183 forks source link

#1035 Distribution new customer enhancements #1061

Closed Ishaanjolly closed 4 days ago

Ishaanjolly commented 5 days ago
Distribution new customer enhancements ## Description

I added n_samples: int = 1000 to _distribution_new_customers and modified this line within:

        if dataset.sizes["chain"] == 1 and dataset.sizes["draw"] == 1:
            # For map fit add a dummy draw dimension
            dataset = dataset.squeeze("draw").expand_dims(draw=range(n_samples))

Additionally:
I added n_samples: int = 1 to distribution_new_customer_recency_frequency and modified this:

self._distribution_new_customers(
            data=data,
            T=T,
            random_seed=random_seed,
            var_names=["recency_frequency"],
            n_samples=n_samples,
        )["recency_frequency"]

Related Issue

Checklist

Modules affected

Type of change


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

codecov[bot] commented 4 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.60%. Comparing base (1a1703c) to head (7b14ccc). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1061 +/- ## ========================================== - Coverage 95.85% 95.60% -0.26% ========================================== Files 39 39 Lines 3934 3934 ========================================== - Hits 3771 3761 -10 - Misses 163 173 +10 ``` | [Flag](https://app.codecov.io/gh/pymc-labs/pymc-marketing/pull/1061/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-labs) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/pymc-labs/pymc-marketing/pull/1061/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-labs) | `95.60% <100.00%> (-0.26%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-labs#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

juanitorduz commented 4 days ago

Thank you @Ishaanjolly !

ColtAllen commented 4 days ago

Sorry that I was late in seeing this, but the same changes can also be applied to ParetoNBDModel. It's also worth noting this PR is related to https://github.com/pymc-labs/pymc-marketing/issues/878 but I'm not entirely sure if that issue is worth pursuing.

juanitorduz commented 4 days ago

Thanks @ColtAllen ! @Ishaanjolly would you wanna do something similar to ParetoNBDModel?

Ishaanjolly commented 4 days ago

Sure, I'll create a new issue for it and pursue it. Thanks @juanitorduz and @ColtAllen

@ColtAllen would also appreciate your suggestions on best way to cache log_p outputs.