การคำนวณค่า incidence เฉลี่ย
คอลัมน์ที่สำคัญที่สุดในตาราง predictor insight graph คือคอลัมน์ target incidence ซึ่งแสดงค่าเฉลี่ยของ target สำหรับแต่ละกลุ่ม
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python
คำแนะนำการฝึกหัด
- สร้าง DataFrame ชื่อ
basetable_incomeที่มีเฉพาะตัวแปรtargetและincome - จัดกลุ่ม DataFrame นี้ตาม
income - คำนวณค่า target incidence เฉลี่ยสำหรับแต่ละกลุ่มใน
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)