視覺化三個數值變數
相較於 3D 圖,有一些「平面」的替代方案更容易解讀,但需要先稍微思考一下如何設計。其中一個不錯的方法,是在散佈圖的 x、y 軸上放兩個數值型解釋變數,並用顏色對應反應變數。
taiwan_real_estate 已可使用。
本練習屬於課程
使用 Python 的 statsmodels 進行迴歸分析:中級
練習說明
- 計算距離最近 MRT 站的平方根,命名為
sqrt_dist_to_mrt_m。 - 使用
taiwan_real_estate資料集,繪製sqrt_dist_to_mrt_m與附近便利商店數量的散佈圖,並以房價作為顏色分類。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Transform dist_to_mrt_m to sqrt_dist_to_mrt_m
taiwan_real_estate["sqrt_dist_to_mrt_m"] = ____
# Draw a scatter plot of sqrt_dist_to_mrt_m vs. n_convenience colored by price_twd_msq
____
# Show the plot
plt.show()