每個類別一個模型
你在整個資料集上擬合的模型,對某些部分的擬合比其他部分更好。值得把資料集分段,分別對不同部分各自跑一次線性模型,看看這些模型之間是否一致或相互矛盾。
taiwan_real_estate 可用。
本練習屬於課程
使用 Python 的 statsmodels 進行迴歸分析:中級
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Filter for rows where house age is 0 to 15 years
taiwan_0_to_15 = ____
# Filter for rows where house age is 15 to 30 years
taiwan_15_to_30 = ____
# Filter for rows where house age is 30 to 45 years
taiwan_30_to_45 = ____