探索批发客户聚类
继续使用批发数据集,您现在可以分析这些簇的特征了。
由于维度超过 2 个,使用散点图来可视化簇会比较困难,因此我们将依靠汇总统计来探索这些簇。在本练习中,您将分析每个簇在三个类别中的平均消费金额。
本练习是课程的一部分
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))