계층적 군집화: 직업 덴드로그램
이전 연습 문제에서 oes 데이터가 추가 전처리 없이도 계층적 군집화에 바로 사용할 수 있음을 확인했어요. 이번 연습에서는 직업별 연평균 급여를 바탕으로 덴드로그램을 만들고, 높이 100,000에서 클러스터를 제안해 보겠습니다.
이 연습은 강의의 일부입니다
R로 배우는 군집 분석
연습 안내
- 직업 간 유클리드 거리를 계산해
dist_oes에 저장하세요. - average 연결 방식을 사용해 계층적 군집화를 수행하고 결과를
hc_oes에 저장하세요. hclust결과에서as.dendrogram()함수를 사용해 덴드로그램 객체dend_oes를 생성하세요.- 덴드로그램을 그리세요.
color_branches()함수를 사용해 절단 높이 100,000에서 클러스터 색을 입힌 새로운 덴드로그램을 만들고, 이를 플로팅하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Calculate Euclidean distance between the occupations
dist_oes <- dist(___, method = ___)
# Generate an average linkage analysis
hc_oes <- hclust(___, method = ___)
# Create a dendrogram object from the hclust variable
dend_oes <- as.dendrogram(___)
# Plot the dendrogram
plot(___)
# Color branches by cluster formed from the cut at a height of 100000
dend_colored <- color_branches(___, h = ___)
# Plot the colored dendrogram
plot(___)