Bayesian Customer Lifetime Values Modeling using PyMC3

Meraldo Antonio21 Apr 2022

Problem

Teams that sell repeatedly to the same customers need a customer lifetime value (CLV) estimate. A customer's departure is never observed, though: a silent customer may have left or may just be between purchases. The standard BG-NBD fit with the lifetimes library returns single point estimates of four parameters. It gives no uncertainty and no way to add what the team already knows about purchase frequency.

Example from the article: a purchase table from CDNow, a CD retailer, where the team assumes a strong intuition that most customers buy about 4 times per week, and nothing is known about how likely customers are to leave.

Solution in brief

Write BG-NBD as a hierarchical Bayesian model in PyMC3. Put priors on the four parameters of the population-level Gamma and Beta distributions, plug in the BG-NBD likelihood, and sample the posteriors with MCMC. Each parameter comes out as a distribution, and the priors carry what the team already believes.

Questions this case answers
  • How to estimate the future value of customers from transaction counts and timing when only repeat purchases are observed and a customer's churn is never directly seen
  • How to combine domain knowledge about behavior rates with data in a probabilistic model so that the parameters come with uncertainty
  • How to estimate customer lifetime value from repeat-purchase history with a Bayesian BG-NBD model?
  • How to put expert knowledge about purchase frequency into a customer-lifetime-value model as priors?

Tools and methods

  • BG-NBD model — models repeat purchases (Gamma-distributed rate λ) and customer deactivation (Beta-distributed probability p).
  • PyMC3 — Bayesian modeling library used to code the model and run the sampler.
  • MCMC (pm.sample) — draws samples from the posteriors of the four parameters.
  • lifetimes — frequentist BG-NBD fit used as a baseline.
Continue reading — it's free

Google or a one-time email code. No password.