始める無料で始める

卸売顧客クラスターを探索する

卸売データセットの分析を続けて、各クラスターの特徴を調べましょう。

3次元以上のデータを扱っているため、クラスターの散布図を可視化するのは難しい状況です。そこで、要約統計量を使って各クラスターを探索します。この演習では、3つのカテゴリーそれぞれについて、クラスターごとの平均支出額を分析します。

この演習はコースの一部です

Rによるクラスター分析

コースを見る

演習の手順

  • count() を使って、各クラスターのサイズを計算しましょう。
  • 高さ15,000でデンドログラムに色を付けてプロットしましょう。
  • summarise_all() 関数を使って、各クラスター内のカテゴリーごとの平均支出額を計算しましょう。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

dist_customers <- dist(customers_spend)
hc_customers <- hclust(dist_customers)
clust_customers <- cutree(hc_customers, h = 15000)
segment_customers <- mutate(customers_spend, cluster = clust_customers)

# Count the number of customers that fall into each cluster
count(___, ___)

# Color the dendrogram based on the height cutoff
dend_customers <- as.dendrogram(hc_customers)
dend_colored <- color_branches(___, ___)

# Plot the colored dendrogram


# Calculate the mean for each category
segment_customers %>% 
  group_by(cluster) %>% 
  summarise_all(list(mean))
コードを編集して実行