模型比較

Generalized Linear Models in Python

Ita Cirovic Donev

Data Science Consultant

偏差(Deviance)

  • 公式 $$ D = -2LL(\beta) $$

  • 誤差量測

  • 偏差越低 $\rightarrow$ 擬合越好
  • 比較基準為 null deviance $\rightarrow$ 僅截距模型
  • 評估
    • 加入隨機雜訊變數,平均會讓偏差減少 1
    • 加入 $p$ 個預測變數,模型偏差應減少超過 $p$
Generalized Linear Models in Python

Python 中的偏差

模型「y ~ distance100」的摘要輸出,並標示對數概似與偏差統計量。

Generalized Linear Models in Python

計算偏差

  • 取出 null deviance 與 deviance
    # Extract null deviance
    print(model.null_deviance)
    
4118.0992
# Extract model deviance
print(model.deviance)
4076.2378
  • 以對數概似計算偏差
    print(-2*model.llf)
    
4076.2378
  • 偏差減少 41.86
  • 納入 distance100 改善了擬合
Generalized Linear Models in Python

模型複雜度

  • model_1model_2,其中
    • $L1 > L2$
    • model_2 的參數數量較多
  • model_2 出現過度擬合
Generalized Linear Models in Python

一起來練習吧!

Generalized Linear Models in Python

Preparing Video For Download...