建立留存與流失表格
你已經學過顧客終生價值(CLV)的主要元素與幾種變形。現在你會使用每月同批次(cohort)活動的資料集來計算留存與流失,接著先探索這些結果,之後再用來推估平均顧客終生價值。
pandas 函式庫已載入為 pd,且已匯入 cohorts_counts 資料集。你可以在主控台自由探索。
本練習屬於課程
Python 的行銷機器學習
練習說明
- 從
cohort_counts的第一欄擷取每個 cohort 的規模(cohort size)。 - 以 cohort 規模去除 cohort 計數,計算留存率。
- 以 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(___)