对两个数值型自变量建模
您已经学习了如何使用一个数值型和一个分类型自变量来构建模型并进行预测。对于两个数值型自变量,建模和预测的代码是一样的,只是在指定用于预测的自变量时有一点小差异。
在这里,您将根据附近便利店数量以及到最近 MRT 车站距离的平方根来建模并预测房价。
taiwan_real_estate 已包含平方根变换后的变量 sqrt_dist_to_mrt_m。itertools.product 也已加载。
本练习是课程的一部分
Python 中级回归:使用 statsmodels
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Fit linear regression of price vs. no. of conv. stores and sqrt dist. to nearest MRT, no interaction
mdl_price_vs_conv_dist = ____
# See the result
print(mdl_price_vs_conv_dist.params)