計算平均發生率
在預測因子洞察圖表的資料表中,最重要的欄位是目標發生率欄。這個欄位會顯示每個分組的目標值平均數。
本練習屬於課程
Python 預測分析入門
練習說明
- 建立只包含變數
target與income的 DataFramebasetable_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)