前処理の構成手順の順番

Pythonで学ぶカスタマーセグメンテーション

Karolis Urbonas

Head of Data Science, Amazon

なぜ順番が重要か

  • 対数変換は正のデータでのみ有効
  • 正規化は負の値を生み、log が動作しない
Pythonで学ぶカスタマーセグメンテーション

手順

  1. 歪みを除く:対数変換
  2. 平均をそろえる(標準化)
  3. 標準偏差をそろえる(スケーリング)
  4. クラスタリング用に別配列として保存
Pythonで学ぶカスタマーセグメンテーション

手順をコード化

# Unskew the data
import numpy as np
datamart_log = np.log(datamart_rfm)

# Normalize the variables from sklearn.preprocessing import StandardScaler scaler = StandardScaler() scaler.fit(datamart_log)
# Store for clustering datamart_normalized = scaler.transform(datamart_log)
Pythonで学ぶカスタマーセグメンテーション

RFMデータで実践

Pythonで学ぶカスタマーセグメンテーション

Preparing Video For Download...