CamDavidsonPilon / lifetimes

Lifetime value in Python
MIT License
1.45k stars 373 forks source link

How `customer_lifetime_value` is Calculated #300

Closed jonimatix closed 1 week ago

jonimatix commented 4 years ago

Hello,

When calling ggf.customer_lifetime_value function as below, the function expects the bgf model (1st parameter) to predict the number of future transactions in the period.

ggf.customer_lifetime_value(
    bgf, #the model to use to predict the number of future transactions
    returning_customers_summary['frequency'],
    returning_customers_summary['recency'],
    returning_customers_summary['T'],
    returning_customers_summary['monetary_value'],
    time = 6, # months
    discount_rate = 0)

The CLV output from the above function call should equal the multiplication of the output from bgf.predict (expected number of transactions) and ggf.conditional_expected_average_profit (expected avg profit per transaction)?

In which case will the above hold true (or not)?

Thanks

psygo commented 4 years ago

I haven't yet taken a thorough look at that function, but it should use the models' estimates to calculate the CLV with the discounted cash flow formula. The fitter's method should be calling the _customer_lifetime_value() function in the utils.py file.

ywu-stats commented 4 years ago

Having the same question here. If I have the discount_rate=0, is future CLV= predicted_puchases * conditional_expected_average_profit ?

andrewng88 commented 4 years ago

Can someone please explain the usage of discount_rate? Is this pegged on existing interest rate for business? Thanks

ywu-stats commented 4 years ago

Here is an example with my real data:

frequency_cal: 20 recency_cal: 482days
T_cal: 500days
monetary_value_cal :74$ frequency_holdout:21 monetary_value_holdout:39$
duration_holdout: 365 days

predicted_purchases: 12 days
predicted_monetary_value:

ggf.conditional_expected_average_profit((
    data['frequency_cal'],
    data['monetary_value_cal']
)) :69$ 

CLV: ggf.customer_lifetime_value(
    bgf, #the model to use to predict the number of future transactions
    data['frequency_cal'],
    data['recency_cal'],
    data['T_cal'],
    data['monetary_value'],
    time=365, # days
    discount_rate=0 ,
    freq="D"): 25046.07$ (this is way high....) 

To me, 12days69 is much closer to 21days39$ which is actual. Plus I'm still confused why purchase frequency is in days unit but monetary value is avg per order not orderdays...

linchenkarenUT commented 3 years ago

@ywu-stats Sorry, it's a pretty last response but do you have any idea why the monetary value is avg per order now? I am also confused about this problem! Thanks