開始使用免費開始

探索留存與流失

現在你已經計算出每月客群(cohort)的留存與流失指標,可以進一步計算整體的平均留存率與平均流失率。你會連續使用兩次 .mean()(稱為「chaining」)來得到整體平均。請記得從計算中排除第 1 個月(第一欄)的數值,因為在客戶加入的第 1 個月,留存固定為 100%,流失固定為 0%,對所有 cohort 都相同。

pandasnumpy 函式庫已分別以 pdnp 載入。你在前一個練習建立的每月 retentionchurn 資料集也已匯入。

本練習屬於課程

Python 的行銷機器學習

檢視課程

練習說明

  • 計算平均留存率。
  • 計算平均流失率。
  • 印出四捨五入後的留存與流失率。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Calculate the mean retention rate
retention_rate = retention.iloc[:,1:].mean().___()

# Calculate the mean churn rate
churn_rate = churn.iloc[:,1:].mean().___()

# Print rounded retention and churn rates
print('Retention rate: {:.2f}; Churn rate: {:.2f}'.format(___, churn_rate))
編輯並執行程式碼