google / lifetime_value

Apache License 2.0
320 stars 84 forks source link

How are LTV distributions calculated? #3

Open JohanWork opened 2 years ago

JohanWork commented 2 years ago

Thank you for making the code for the loss function, metrics and example notebooks open source.

From the last paragraph in section 3:

Another key advantage of the ZILN loss is that it provides a full prediction distribution. We obtain not only the probability of returning but also the value distribution of LTV for returning customers. In addition to mean LTV prediction, the uncertainty of LTV predictions can be assessed using quantiles of a lognormal distribution as in general quantile regression.

To me it is unclear both from checking the code examples and the paper, how the LTV prediction distributions are calculated, can you get them both for a singel predictions and a group of prediction for example?

Thank you!

jarandaf commented 1 year ago

Hi @JohanWork, AFAIK the library simply returns the mean of a LogNormal distribution. Check this method:

https://github.com/google/lifetime_value/blob/dd418967b3ca456b375b0ae8adac38732f7831db/lifetime_value/zero_inflated_lognormal.py#L22

Since loc and scale (parameters of the LogNormal distribution) are returned by the DNN, one can also get not only the mean but any desired quantile. Check this for more details.