การประเมินประสิทธิภาพโมเดล
เพื่อทดสอบว่าแนวทางใดดีกว่ากัน — โมเดลที่ใช้ชุดข้อมูลทั้งหมด หรือโมเดลแยกตามกลุ่มอายุของบ้าน — จำเป็นต้องคำนวณค่าเมตริกบางอย่าง โดยจะเปรียบเทียบค่าสัมประสิทธิ์การตัดสินใจ (coefficient of determination) และค่าความคลาดเคลื่อนมาตรฐานของส่วนที่เหลือ (residual standard error) ของแต่ละโมเดล
โมเดลทั้ง 4 ตัวที่แสดงความสัมพันธ์ระหว่างราคาและจำนวนร้านสะดวกซื้อ (mdl_all_ages, mdl_0_to_15, mdl_15_to_30, และ mdl_30_to_45) พร้อมใช้งานแล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Regression ระดับกลางด้วย statsmodels ใน Python
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Print the coeff. of determination for mdl_all_ages
print("R-squared for mdl_all_ages: ", ____)
# Print the coeff. of determination for mdl_0_to_15
print("R-squared for mdl_0_to_15: ", ____)
# Print the coeff. of determination for mdl_15_to_30
print("R-squared for mdl_15_to_30: ", ____)
# Print the coeff. of determination for mdl_30_to_45
print("R-squared for mdl_30_to_45: ", ____)