Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Time-Invariant Covariates to ParetoNBD and BG/NBD Models #134

Open
ColtAllen opened this issue Jan 25, 2023 · 8 comments
Open

Add Time-Invariant Covariates to ParetoNBD and BG/NBD Models #134

ColtAllen opened this issue Jan 25, 2023 · 8 comments
Labels
CLV enhancement New feature or request

Comments

@ColtAllen
Copy link
Collaborator

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 ColtAllen added enhancement New feature or request CLV labels Jan 25, 2023
@juanitorduz
Copy link
Collaborator

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

@ColtAllen
Copy link
Collaborator Author

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.

@juanitorduz
Copy link
Collaborator

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".

@navish92
Copy link

navish92 commented Feb 7, 2024

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?

@ColtAllen
Copy link
Collaborator Author

Thanks @navish92,

Covariate support for BetaGeoModel will be added after #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.

@navish92
Copy link

navish92 commented Feb 9, 2024

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!

@ColtAllen
Copy link
Collaborator Author

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
Copy link
Collaborator Author

@navish92 #1390 will add static covariates to BetaGeoModel.

@ColtAllen ColtAllen changed the title Add Time-Invariant Covariates to CLV Models Add Time-Invariant Covariates to ParetoNBD and BG/NBD Models Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLV enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants