計算基本 CLV
你現在已經準備好用三種不同的方法來計算顧客存留期的平均值了!在本練習中,你將計算「基本 CLV」,也就是用每月平均花費乘上預估的顧客生命週期。
pandas 與 numpy 函式庫已分別載入為 pd 與 np。online 資料集也已為你匯入。
本練習屬於課程
Python 的行銷機器學習
練習說明
- 以
CustomerID進行分組,計算每位顧客的每月花費。 - 計算每月平均花費。
- 將生命週期(lifespan)設為 36 個月。
- 以每月平均花費乘上生命週期,計算基本 CLV。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Calculate monthly spend per customer
monthly_revenue = online.___(['___','InvoiceMonth'])['TotalSum'].___()
# Calculate average monthly spend
monthly_revenue = np.___(monthly_revenue)
# Define lifespan to 36 months
lifespan_months = ___
# Calculate basic CLV
clv_basic = ___ * lifespan_months
# Print the basic CLV value
print('Average basic CLV is {:.1f} USD'.format(clv_basic))