視覺化數值對分類變數
如果解釋變數是分類型,你之前用來視覺化資料的散佈圖就不太合適。更好的做法是為每個類別各畫一個直方圖。
臺灣不動產資料集包含一個關於每間房屋屋齡的分類變數。屋齡被分成 3 組:0 到 15 年、15 到 30 年,以及 30 到 45 年。
taiwan_real_estate 已可使用。
本練習屬於課程
使用 Python 中的 statsmodels 進行回歸入門
練習說明
- 使用
taiwan_real_estate,繪製price_twd_msq的直方圖,bins設為10。依house_age_years分面,產生 3 個子圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Histograms of price_twd_msq with 10 bins, split by the age of each house
sns.____(data=____,
x=____,
____=____,
____=____)
# Show the plot
____