지배적인 색은 몇 가지일까요?
다음 이미지는 matplotlib의 image 클래스에서 imread() 함수를 사용해 불러왔습니다.

RGB 값은 DataFrame batman_df에 저장되어 있습니다. 이 RGB 값은 whiten() 함수를 사용해 표준화했으며, scaled_red, scaled_blue, scaled_green 열에 저장했습니다.
이 DataFrame으로 엘보우 플롯을 만들어 보세요. 지배적인 색은 몇 가지인가요?
이 연습은 강의의 일부입니다
Python으로 배우는 군집 분석
연습 안내
num_clusters의 각 값에 대해kmeans()함수를 실행해 왜곡(distortion) 값 목록을 만드세요.- 목록
num_clusters와distortions로 DataFrameelbow_plot을 만드세요. seaborn의.lineplot()메서드로 x축은num_clusters, y축은distortions로 지정해 데이터를 그리세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
distortions = []
num_clusters = range(1, 7)
# Create a list of distortions from the kmeans function
for i in ____:
cluster_centers, distortion = ____
distortions.append(____)
# Create a DataFrame with two lists, num_clusters and distortions
elbow_plot = pd.DataFrame(____)
# Create a line plot of num_clusters and distortions
sns.lineplot(x=____, y=____, data = elbow_plot)
plt.xticks(num_clusters)
plt.show()