计算传统 CLV
现在,您将计算一种最常见的描述性 CLV 模型,它同时考虑留存率与流失率。这个方法能给出更稳健的估计,但前提是假设需要验证。请在将此方法应用到您自己的场景前,先回顾视频幻灯片。
pandas 与 numpy 库分别已作为 pd 与 np 载入。online 与 retention 数据集也已为您导入。
本练习是课程的一部分
Python 营销中的机器学习
练习说明
- 以
CustomerID与InvoiceMonth分组,计算每位客户的月度消费。 - 计算平均月度留存率。
- 计算平均月度流失率。
- 用月度平均消费乘以「留存率与流失率之比」来计算传统 CLV。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Calculate monthly spend per customer
monthly_revenue = online.___(['CustomerID','InvoiceMonth'])['___'].sum().mean()
# Calculate average monthly retention rate
retention_rate = retention.iloc[:,1:].mean().mean()
# Calculate average monthly churn rate
churn_rate = 1 - ___
# Calculate traditional CLV
clv_traditional = monthly_revenue * (___ / churn_rate)
# Print traditional CLV and the retention rate values
print('Average traditional CLV is {:.1f} USD at {:.1f} % retention_rate'.format(clv_traditional, retention_rate*100))