评估模型性能
为了判断哪种方法更好——使用整个数据集的模型,还是按房龄分组的模型——您需要计算一些指标。在这里,您将比较每个模型的判定系数和残差标准误。
关于房价与便利店数量关系的四个模型(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: ", ____)