評估模型效能
為了測試哪個方法較佳——使用整個資料集的模型,或是依屋齡分類的模型——你需要計算一些指標。這裡你會比較每個模型的決定係數與殘差標準誤。
已提供 4 個以房價對便利商店數量為解釋變數的模型(mdl_all_ages、mdl_0_to_15、mdl_15_to_30、mdl_30_to_45)。
本練習屬於課程
使用 Python 的 statsmodels 進行迴歸分析:中級
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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: ", ____)