可视化两个数值型解释变量
可视化两个数值型解释变量的代码与您之前见过的一样:先绘制一层真实数据点,再叠加一层预测点,用来对比两者的吻合程度。对于两个数值型解释变量,预测点这一层会呈现为一个网格。
taiwan_real_estate 和 prediction_data 已提供,并包含平方根变换后的变量 sqrt_dist_to_mrt_m。
本练习是课程的一部分
Python 中级回归:使用 statsmodels
练习说明
- 使用
taiwan_real_estate,绘制以sqrt_dist_to_mrt_m为横轴、n_convenience为纵轴、并按price_twd_msq着色的散点图。 - 再绘制一层基于
prediction_data的散点图,不显示图例,并将marker设为"s"(方形标记)。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create scatter plot of taiwan_real_estate
____
# Create scatter plot of prediction_data without legend
____
# Show the plot
plt.show()