比較決定係數
回想一下,決定係數是用來衡量線性回歸線與觀察值貼合程度的指標。在線性回歸中納入多個解釋變數的一個重要動機,是相較於只考慮單一解釋變數,你可以提升模型的貼合度。
接下來你會比較 3 個臺灣房價模型的決定係數,看看哪一個表現最好。
mdl_price_vs_conv、mdl_price_vs_age 與 mdl_price_vs_both 都已經配適完成,可直接使用。
本練習屬於課程
使用 Python 的 statsmodels 進行迴歸分析:中級
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the coeffs of determination for mdl_price_vs_conv
print("rsquared_conv: ", ____)
print("rsquared_adj_conv: ", ____)
# Print the coeffs of determination for mdl_price_vs_age
print("rsquared_age: ", ____)
print("rsquared_adj_age: ", ____)
# Print the coeffs of determination for mdl_price_vs_both
print("rsquared_both: ", ____)
print("rsquared_adj_both: ", ____)