顧客與產品分群基礎

Python 的行銷機器學習

Karolis Urbonas

Head of Analytics & Science, Amazon

資料格式

# Customer by product/service matrix
wholesale.head()

批發資料表頭

Python 的行銷機器學習

非監督式學習模型

  • 階層式分群
  • K-means
  • 非負矩陣分解(NMF)
  • 雙向分群
  • 高斯混合模型(GMM)
  • 還有更多
Python 的行銷機器學習

非監督式學習模型

  • 階層式分群
  • K-means
  • 非負矩陣分解(NMF)
  • 雙向分群
  • 高斯混合模型(GMM)
  • 還有更多
Python 的行銷機器學習

非監督式學習步驟

  1. 初始化模型
  2. 擬合模型
  3. 指派叢集值
  4. 探索結果
Python 的行銷機器學習

探索變數

wholesale.agg(['mean','std']).round(0)
        Fresh    Milk  Grocery  Frozen  Detergents_Paper  Delicassen
mean  12000.0  5796.0   7951.0  3072.0            2881.0      1525.0
std   12647.0  7380.0   9503.0  4855.0            4768.0      2820.0
# Get the statistics
averages = wholesale.mean()
st_dev = wholesale.std()
x_names = wholesale.columns
x_ix = np.arange(wholesale.shape[1])

# Plot the data import matplotlib.pyplot as plt plt.bar(x_ix-0.2, averages, color='grey', label='Average', width=0.4) plt.bar(x_ix+0.2, st_dev, color='orange', label='Standard Deviation', width=0.4) plt.xticks(x_ix, x_names, rotation=90) plt.legend() plt.show()
Python 的行銷機器學習

平均與標準差的長條圖

長條圖

Python 的行銷機器學習

用配對圖檢視分布

import seaborn as sns
sns.pairplot(wholesale, diag_kind='kde')
plt.show()
Python 的行銷機器學習

配對圖檢視

配對圖(原始)

Python 的行銷機器學習

一起來練習吧!

Python 的行銷機器學習

Preparing Video For Download...