開始使用免費開始

計算平均發生率

在預測因子洞察圖表的資料表中,最重要的欄位是目標發生率欄。這個欄位會顯示每個分組的目標值平均數。

本練習屬於課程

Python 預測分析入門

檢視課程

練習說明

  • 建立只包含變數 targetincome 的 DataFrame basetable_income
  • income 對這個 DataFrame 進行分組。
  • 計算 income 各分組的目標平均發生率。

動手互動練習

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

# Select the income and target columns
basetable_income = basetable[["____","____"]]

# Group basetable_income by income
groups = basetable_income.____("____")

# Calculate the target incidence and print the result
incidence = groups["____"].agg(Incidence = '____').reset_index()
print(incidence)
編輯並執行程式碼