시작하기무료로 시작하기

도매 고객 클러스터 탐색

도매 데이터셋 작업을 이어서, 이제 각 클러스터의 특성을 분석해 보려고 합니다.

차원이 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))
코드 편집 및 실행