시작하기무료로 시작하기

분명한 클러스터에서의 Elbow 방법

이번에는 comic con 데이터셋을 사용해, 뚜렷하고 잘 정의된 클러스터가 있는 데이터에서 elbow 플롯이 어떻게 나타나는지 살펴보겠습니다. 연습 문제를 진행하기 전에 데이터 포인트를 먼저 시각화해 보셔도 좋아요.

데이터는 pandas DataFrame인 comic_con에 저장되어 있습니다. x_scaledy_scaled는 특정 시점 사람들의 표준화된 X, Y 좌표를 담은 열 이름입니다.

이 연습은 강의의 일부입니다

Python으로 배우는 군집 분석

강의 보기

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

distortions = []
num_clusters = range(1, 7)

# Create a list of distortions from the kmeans function
for i in ____:
    cluster_centers, distortion = ____
    distortions.append(distortion)

# Create a DataFrame with two lists - num_clusters, distortions
elbow_plot = pd.DataFrame({'num_clusters': ____, 'distortions': ____})

# Creat a line plot of num_clusters and distortions
sns.lineplot(x=____, y=____, data = ____)
plt.xticks(num_clusters)
plt.show()
코드 편집 및 실행