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
587 stars 138 forks source link

Add Seasonality to `CLV` Models #219

Open ColtAllen opened 1 year ago

ColtAllen commented 1 year ago

Section 6 in https://www.brucehardie.com/notes/040/time-varying_covariates_in_BGNBD.pdf describes how BetaGeoModel can be extended to account for seasonality. I'm pretty sure this same methodology can be applied to the ParetoNBDModel and other models. Not gonna lie though - this will be involved and span multiple PRs.

Expanding clv.utils.clv_summary() for seasonality periods (and transactions within those periods) demands considerable pandas knowledge and will be the hardest part of this. Prophet might be a useful codebase for ideas. For the models themselves, hopefully logp can be wrapped in a pytensor.switch() statement to go back & forth between the high/low/etc. seasons.

juanitorduz commented 1 year ago

Nice idea! I have not gone into the details, but we already have a function to generate Fourier modes a la Prophet https://github.com/pymc-labs/pymc-marketing/blob/main/pymc_marketing/mmm/utils.py#L6-#L35 ;) I plan to incorporate seasonality for the current mmm class.