클러스터 분석을 위한 데이터 준비

Python으로 배우는 군집 분석

Shaumik Daityari

Business Analyst

왜 클러스터링 전에 데이터를 준비해야 할까요?

  • 변수 단위가 비교 불가함(제품 크기: cm, 가격: $)
  • 같은 단위여도 스케일·분산이 크게 다름(시리얼, 여행 지출)
  • 원시 데이터는 클러스터링에 편향을 유발할 수 있음
  • 클러스터가 한 변수에 과도하게 의존할 수 있음
  • 해결: 개별 변수 정규화
Python으로 배우는 군집 분석

데이터 정규화

정규화: 표준편차 1로 데이터 스케일 재조정 과정

x_new = x / std_dev(x)

from scipy.cluster.vq import whiten
data = [5, 1, 3, 3, 2, 3, 3, 8, 1, 2, 2, 3, 5]
scaled_data = whiten(data)
print(scaled_data)
[2.73, 0.55, 1.64, 1.64, 1.09, 1.64, 1.64, 4.36, 0.55, 1.09, 1.09, 1.64, 2.73]
Python으로 배우는 군집 분석

예시: 데이터 정규화

# Import plotting library
from matplotlib import pyplot as plt

# Initialize original, scaled data
plt.plot(data, 
         label="original")
plt.plot(scaled_data, 
         label="scaled")
# Show legend and display plot
plt.legend()
plt.show()

Python으로 배우는 군집 분석

다음: 직접 해보는 연습

Python으로 배우는 군집 분석

Preparing Video For Download...