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
683 stars 190 forks source link

Add posterior population distributions for `BetaGeoModel` #301

Closed wd60622 closed 1 year ago

wd60622 commented 1 year ago

Think one of the cool attributes on the BetaGeoModel assumptions are the population distributions.

Think they are useful for understanding the fit high level but also might be interesting to see population shift the time varying parameter version or other variations down the line

Seems like it can be implemented pretty straight forward and wrapped in a function like some of the GammaGamma Models methods

with pm.Model(): 
    # Dummy for the sampling
    a = pm.HalfFlat("a")
    b = pm.HalfFlat("b")
    alpha = pm.HalfFlat("alpha")
    r = pm.HalfFlat("r")

    population_dropout = pm.Beta("population_dropout", alpha=a, beta=b)
    # Need to double check this parameterization
    population_purchase_rate = pm.Gamma("population_purchase_rate", alpha=alpha, beta=r)

    pp = pm.sample_posterior_predictive(
        self.fit_results, 
        var_names=["population_dropout", "population_purchase_rate"], 
        ... # would be function args like in gamma gamma
    ).posterior_predictive

Any thoughts on if this would be a valuable addition? Would be willing to implement and add to the docs 😄

ricardoV94 commented 1 year ago

@wd60622 would that be equivalent to distribution_new_customer_spend in the GammaGamma model?

If so, I think it would be a good addition.

wd60622 commented 1 year ago

Think that is closely related, goes with two of the assumptions of the generation process.

Doesn't have any specific customer in mind like those methods.

From these samples, we could create these figures (taken from here) or make statistics about the population

beta-geo-pop-params