具有易于理解系数的交互项
前一个包含交互项的模型返回了不太容易解释的系数。为澄清模型在预测什么,您可以重新表述模型,使其返回更容易理解的系数。为进一步说明,您可以将结果与分别在各房龄类别上拟合的模型进行比较(mdl_0_to_15、mdl_15_to_30 和 mdl_30_to_45)。
已提供 taiwan_real_estate、mdl_0_to_15、mdl_15_to_30 和 mdl_30_to_45。
本练习是课程的一部分
Python 中级回归:使用 statsmodels
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Model price vs. house age plus an interaction, no intercept
mdl_readable_inter = ____
# Print the coefficients for mdl_0_to_15
print("mdl_0_to_15 coefficients:", "\n", ____)
# Print the coefficients for mdl_15_to_30
print("mdl_15_to_30 coefficients:", "\n", ____)
# Print the coefficients for mdl_30_to_45
print("mdl_30_to_45 coefficients:", "\n", ____)
# Print the coefficients for mdl_readable_inter
print("\n", "mdl_readable_inter coefficients:", "\n", mdl_readable_inter.params)