pymc-marketing icon indicating copy to clipboard operation
pymc-marketing copied to clipboard

Add Time-Invariant Covariates to CLV Models

Open ColtAllen opened this issue 2 years ago • 7 comments
trafficstars

Both the Beta-Geo/NBD and Pareto/NBD models can be extended rather easily to support time-invariant covariates:

https://www.brucehardie.com/notes/019/time_invariant_covariates.pdf

ColtAllen avatar Jan 25 '23 14:01 ColtAllen

In https://juanitorduz.github.io/bg_nbd_pymc/ I tried to do so :)

juanitorduz avatar Feb 03 '23 11:02 juanitorduz

Instead of adding separate covariate models, I think it would save us a lot of redundancy to simply extend the existing BetaGeoModel and upcoming ParetoNBDModel. The only additional code required seems to just be 2-3 more priors in the __init__ method and input parameters for the covariates. Everything else is identical and these extra priors could be omitted by a conditional if the covariates are unspecified.

In https://juanitorduz.github.io/bg_nbd_pymc/ I tried to do so :)

You've added to this since I last read it! You mentioned the BG/NBD covariate model may benefit from an alternative formulation for the likelihood (which is provided in the PDF link) but I had a lot of success with hierarchical pooling of hyperpriors in the BG/NBD implementation I did for btyd:

https://github.com/ColtAllen/btyd/blob/main/btyd/models/beta_geo_model.py#L97

That may be worth trying before doing any logp modifications, because btyd also has a BetaGeoCovarsFitter() that uses the same likelihood as BetaGeoFitter and gives identical results when np.ones are provided for the covariates.

ColtAllen avatar Feb 04 '23 06:02 ColtAllen

Hey! thanks for the feedback! I will definitely take a look at your work on hierarchical models! Your comments make a lot of sense and might be in the right direction! My initial approach was a more "brute force approach".

juanitorduz avatar Feb 06 '23 08:02 juanitorduz

Hi @ColtAllen Thanks for the amazing contributions to this & BTYD package. Curious if time-invariant covariates for BG/NBD was added or is in the pipeline?

navish92 avatar Feb 07 '24 22:02 navish92

Thanks @navish92,

Covariate support for BetaGeoModel will be added after https://github.com/pymc-labs/pymc-marketing/issues/527 is resolved. If you have any feedback on that issue I'd be interested, because end-user convenience is a significant factor of it.

In the meantime, do not discount ParetoNBDModel, because although it is slower to fit than BetaGeoModel, it has greater functionality. If probability_alive is important to your use case, it also has superior performance.

ColtAllen avatar Feb 09 '24 19:02 ColtAllen

HI @ColtAllen Thanks for pointing to issue #527 I will take a comprehensive look and share my thoughts.

I did want to clarify. Is ParetoNBDModel setup to accommodate time invariant covariates at the moment? From what I could understand, it wasnt yet? I did notice there's an open PR that is almost ready adding this capability.

Thanks!

navish92 avatar Feb 09 '24 22:02 navish92

Is ParetoNBDModel setup to accommodate time invariant covariates at the moment? From what I could understand, it wasnt yet?

Correct - it is not. That PR is currently awaiting review, but otherwise is nearly ready.

ColtAllen avatar Feb 10 '24 15:02 ColtAllen