Calculate granular CLV
In this scenario you will use more granular data points at the invoice level. This approach uses more granular data and can give a better customer lifetime value estimate. Make sure you compare the results with the one from the basic CLV model.
The pandas and numpy libraries have been loaded as pd as np respectively. The online dataset has been imported for you.
Bu egzersiz
Machine Learning for Marketing in Python
kursunun bir parçasıdırEgzersiz talimatları
- Group by
InvoiceNoand calculate the mean of theTotalSumcolumn. - Group by
CustomerIDandInvoiceMonthand calculate the mean number of unique monthly invoices per customer. - Define lifespan to 36 months.
- Calculate the granular CLV by multiplying the three previous metrics.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Calculate average revenue per invoice
revenue_per_purchase = online.___(['___'])['TotalSum'].mean().mean()
# Calculate average number of unique invoices per customer per month
frequency_per_month = online.___(['CustomerID','InvoiceMonth'])['___'].___().mean()
# Define lifespan to 36 months
lifespan_months = 36
# Calculate granular CLV
clv_granular = ___ * frequency_per_month * lifespan_months
# Print granular CLV value
print('Average granular CLV is {:.1f} USD'.format(clv_granular))