构建留存与流失表
您已经学习了客户终身价值(Customer Lifetime Value,CLV)的主要组成部分及其若干变体。现在,您将使用按月分组的队列活跃度数据集来计算留存和流失值。随后您会对其进行探索,并在后续用于预估平均客户终身价值。
pandas 库已作为 pd 加载,cohorts_counts 数据集也已导入。您可以在控制台中自由探索。
本练习是课程的一部分
Python 营销中的机器学习
练习说明
- 从
cohort_counts的首列提取各队列规模。 - 通过用各期队列计数除以对应队列规模来计算留存率。
- 通过用 1 减去留存率来计算流失率。
- 打印留存表。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Extract cohort sizes from the first column of cohort_counts
cohort_sizes = cohort_counts.___[:,0]
# Calculate retention by dividing the counts with the cohort sizes
retention = cohort_counts.___(cohort_sizes, axis=0)
# Calculate churn
churn = 1 - ___
# Print the retention table
print(___)