การเปรียบเทียบโมเดล

Generalized Linear Models ใน Python

Ita Cirovic Donev

Data Science Consultant

Deviance

  • สูตร $$ D = -2LL(\beta) $$

  • วัดค่าความผิดพลาด

  • Deviance ต่ำลง $\rightarrow$ โมเดลพอดีข้อมูลดีขึ้น
  • เกณฑ์เปรียบเทียบคือ null deviance $\rightarrow$ โมเดลที่มีแค่ intercept
  • การประเมิน
    • การเพิ่มตัวแปรสุ่มจะลด deviance ได้เฉลี่ย 1 หน่วย
    • การเพิ่ม $p$ ตัวพยากรณ์ควรทำให้ deviance ลดลงมากกว่า $p$
Generalized Linear Models ใน Python

Deviance ใน Python

ผลลัพธ์สรุปของโมเดล 'y ~ distance100' โดยเน้นที่ log-likelihood และค่าสถิติ deviance

Generalized Linear Models ใน Python

คำนวณ deviance

  • ดึงค่า null deviance และ deviance
    # Extract null deviance
    print(model.null_deviance)
    
4118.0992
# Extract model deviance
print(model.deviance)
4076.2378
  • คำนวณ deviance จาก log likelihood
    print(-2*model.llf)
    
4076.2378
  • Deviance ลดลง 41.86
  • การเพิ่ม distance100 ช่วยให้โมเดลพอดีข้อมูลดีขึ้น
Generalized Linear Models ใน Python

ความซับซ้อนของโมเดล

  • model_1 และ model_2 โดยที่
    • $L1 > L2$
    • model_2 มีจำนวนพารามิเตอร์มากกว่า
  • model_2 เกิด overfitting
Generalized Linear Models ใน Python

มาฝึกกันเถอะ!

Generalized Linear Models ใน Python

Preparing Video For Download...