ARI로 클러스터링에서의 특성 중요도 구하기
Adjusted Rand Index(ARI)를 활용해 이전 연습 문제에서 사용한 고객 데이터셋(이미 X에 로드됨)에서 각 특성을 제거했을 때 클러스터 할당에 미치는 영향을 정량적으로 측정해 보세요.
adjusted_rand_score() 함수와 column_names 변수는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Python으로 배우는 Explainable AI
연습 안내
original_clusters에 원본 클러스터 할당을 구하세요.- for 루프에서 특성을 하나씩 제거하고 결과를
X_reduced에 저장하세요. X_reduced에 K-means를 적용해reduced_clusters를 구하세요.reduced_clusters와original_clusters간 ARI를 바탕으로 특성importance를 계산하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
kmeans = KMeans(n_clusters=5, random_state=10, n_init=10).fit(X)
# Derive original clusters
original_clusters = ____
for i in range(X.shape[1]):
# Remove feature at index i
X_reduced = ____
# Derive reduced clusters
reduced_clusters = ____
# Derive feature importance
importance = ____
print(f'{column_names[i]}: {importance}')