question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BG/NBD Model in PyMC

See original GitHub issue

Hey! I have recently drafted a BG/NBD model in PyMC, see https://juanitorduz.github.io/bg_nbd_pymc/ In particular I have also added the possibility to add time-invariant regressors (even though the sampler and/or model parametrisation need some improvements). Other models from the lifetimes package can be ported to PyMC in a similar way (because the lifetimes package has all the log-likelihood functions written in numpy already).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juanitorduzcommented, Apr 17, 2022

That sounds very exiting! Let me know if you need som input or want me to test some of the ongoing features. As a side remark, I also did a small re-write in pymc for the gamma-gamma model, see https://juanitorduz.github.io/gamma_gamma_pymc/

1reaction
ColtAllencommented, Mar 22, 2022

Hey @juanitorduz ,

This is great! I really hope you can join the Zoom kickoff call for this project next Sunday. Information to join is in a Discussion post in this repo as well as here:

https://github.com/CamDavidsonPilon/lifetimes/issues/414#issuecomment-1073247582

I’ve been working on a BG/NBD model as well, but will be experimenting with ADVI or SVGD for inference because MCMC training can go on for days, compared to minutes with ADVI. However, MCMC is also the only way to derive the true posterior distribution (rather than an approximation as is the case with ADVI or SVGD). A more performant option for MCMC may be Stan, which prophet uses for inference of its time series model parameters. @alexpavlakis wrote a script in Stan for the Gamma-Gamma model, but I haven’t tested it yet in CmndStanPy.

As you mentioned, the tricky thing about these algorithms is choosing an appropriate prior, and my goal is to make this library as user-friendly as possible. Fortunately in the case of the Pareto/NBD model, there is a research paper on this very topic:

Worth the effort? Comparison of different MCMC algorithms for estimating the Pareto/NBD model

I’ve saved several research papers on covariates and other modeling alternatives and will be posting links to the README soon. None of them are pay-walled, but to be safe I can also look into uploading my saved copies to the repo. One of these papers even covers a Pareto/NBD model with time-varying covariates, but it is immensely more compute-intensive than the standard Pareto/NBD and only performs significantly better for customers with lifetimes of 3 years or more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bayesian Customer Lifetime Values Modeling using PyMC3
Implementing BG-NBD, a probabilistic hierarchical model, using PyMC3 to analyze customer purchase behavior. Source: Unsplash. Customer lifetime ...
Read more >
BG/NBD (Beta-Geometric/Negative Binomial) Model for ...
Hi, I'm trying to implement the BG/NBD model from Fader et al 2005 (“Counting Your Customers” the Easy Way: An Alternative to the...
Read more >
Customer Life Time Value Prediction by Using BG-NBD ...
BG-NBD Model will model each customer's purchase behaviours' distribution and will predict the expected number of transactions for each customer ...
Read more >
Why do Pareto/NBD models require custom likelihood ...
A) A customer not returning is directly modeled by the Geometric process. B) The model integrates out each customer's parameters using their ...
Read more >
ColtAllen/btyd: Buy Till You Die and Customer ... - GitHub
Buy Till You Die and Customer Lifetime Value statistical models in Python. ... and Bayesian PyMC model implementations are now in Beta.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found