開始使用免費開始

探索顧客商品購買資料集

你已在影片練習中看過「顧客 × 商品購買」資料集,現在要繪製一些探索性圖表,了解各變數的分布與它們之間的關係。這裡你會探索 wholesale 資料集,並使用 seaborn 函式庫的 pairplot 函式,同時繪出各變數兩兩之間的關係圖,以及每個變數的估計分布。這一步很重要,用來檢視分布型態與變數關聯,並據此判斷是否需要進一步的資料前處理。

pandas 已以 pd 載入,seabornsns 載入,matplotlib.pyplotplt 載入。此外,wholesale 資料集已載入為一個 pandas 的 DataFrame。

本練習屬於課程

Python 的行銷機器學習

檢視課程

練習說明

  • 列印 wholesale 資料集的前幾列
  • 繪製各變數之間的成對關係圖
  • 顯示圖表。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Print the header of the `wholesale` dataset
print(___.head())

# Plot the pairwise relationships between the variables
sns.pairplot(___, diag_kind='kde')

# Display the chart
plt.___()
編輯並執行程式碼