비지도 학습 모델 설명

Python으로 배우는 Explainable AI

Fouad Trad

Machine Learning Engineer

클러스터링

사전 라벨 없이 유사한 데이터 포인트를 그룹화

2개 특성을 가진 데이터가 3개 클러스터로 나뉘고 각 클러스터에 중심이 있는 이미지.

Python으로 배우는 Explainable AI

실루엣 점수

  • 클러스터링 품질을 측정
  • 범위: -1 ~ 1
    • 1 → 잘 분리된 클러스터

잘 분리된 클러스터를 보여주는 이미지.

Python으로 배우는 Explainable AI

실루엣 점수

  • 클러스터링 품질을 측정
  • 범위: -1 ~ 1
    • 1 → 잘 분리된 클러스터
    • -1 → 잘못 배정된 포인트

명확한 분리가 없는 클러스터를 보여주는 이미지.

Python으로 배우는 Explainable AI

클러스터 품질에 대한 특성 영향

2개 특성을 가진 데이터셋을 클러스터링한 결과를 보여주는 이미지.

Python으로 배우는 Explainable AI

클러스터 품질에 대한 특성 영향

한 특성을 제거해 재학습한 뒤의 클러스터링 결과를 보여주는 이미지.

Python으로 배우는 Explainable AI

클러스터 품질에 대한 특성 영향

제거된 특성의 영향도를 두 특성이 모두 있을 때의 실루엣 점수와 해당 특성을 제거했을 때의 실루엣 점수 차이로 계산하는 공식을 보여주는 이미지.

  • $\text{Impact(}f) > 0$ → $f$가 긍정적 기여
  • $\text{Impact(}f) < 0$ → $f$가 잡음을 도입
Python으로 배우는 Explainable AI

학생 성취도 데이터셋

age health status absences G1 G2 G3
18 3 4 0 11 11
17 3 2 9 11 11
15 3 6 12 13 12
15 5 0 14 14 14
16 5 0 11 13 13

 

X: 특성으로 이루어진 배열

Python으로 배우는 Explainable AI

클러스터 품질에 대한 특성 영향 계산

from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score


kmeans = KMeans(n_clusters=2).fit(X)
original_score = silhouette_score(X, kmeans.labels_)
for i in range(X.shape[1]):
X_reduced = np.delete(X, i, axis=1)
kmeans.fit(X_reduced)
new_score = silhouette_score(X_reduced, kmeans.labels_)
impact = original_score - new_score print(f'Feature {column_names[i]}: Impact = {impact}')
Python으로 배우는 Explainable AI

클러스터 품질에 대한 특성 영향 계산

Feature age: Impact = 0.05199181662741281
Feature health status: Impact = 0.06046737420227638
Feature absences: Impact = 0.031290940582026694
Feature G1: Impact = -0.025746421940652353
Feature G2: Impact = -0.02578292339364119
Feature G3: Impact = -0.03163419458330158
Python으로 배우는 Explainable AI

Adjusted Rand Index (ARI)

  • 클러스터 할당의 일치도를 측정

주어진 데이터셋에 대해 유사한 두 개의 클러스터 할당을 보여주는 이미지.

  • 최대 ARI = 1 → 완전한 정렬
Python으로 배우는 Explainable AI

Adjusted Rand Index (ARI)

  • 클러스터 할당의 일치도를 측정

같은 데이터셋에 대해 다른 두 개의 클러스터 할당을 보여주는 이미지.

  • 최대 ARI = 1 → 완전한 정렬
  • ARI가 낮을수록 → 클러스터링 차이가 큼
Python으로 배우는 Explainable AI

클러스터 할당에 대한 특성 중요도

   

  • 특성을 하나씩 제거
  • $\text{Importance}(f) = 1 - \text{ARI (original clusters, modified clusters)}$
  • ARI가 낮음 → $\text(1 - ARI)$ 큼 → 중요한 특성
Python으로 배우는 Explainable AI

클러스터 할당에 대한 특성 중요도

from sklearn.metrics import adjusted_rand_score

kmeans = KMeans(n_clusters=2).fit(X) original_clusters = kmeans.predict(X)
for i in range(X.shape[1]):
X_reduced = np.delete(X, i, axis=1)
reduced_clusters = kmeans.fit_predict(X_reduced)
importance = 1 - adjusted_rand_score(original_clusters, reduced_clusters) print(f'{df.columns[i]}: {importance}')
age: 0.0
health status: 0.9995376368119572
absences: 0.0
G1: 0.0
G2: 0.6204069909514572
G3: 0.6204069909514572
Python으로 배우는 Explainable AI

Ayo berlatih!

Python으로 배우는 Explainable AI

Preparing Video For Download...