kNN 거리 점수 시각화

R로 시작하는 이상치 탐지 입문

Alastair Rushworth

Data Scientist

특성 스케일 표준화

plot(Width ~ Height, data = furniture)

R로 시작하는 이상치 탐지 입문

특성 표준화

furniture_scaled <- scale(furniture)

plot(Width ~ Height, data = furniture_scaled)

R로 시작하는 이상치 탐지 입문

거리 점수 생성 및 추가

거리 행렬

furniture_scaled <- scale(furniture)
furniture_knn    <- get.knn(furniture_scaled, 5)

점수 계산 및 추가

furniture$score  <- rowMeans(furniture_knn$nn.dist)

head(furniture, 4)
   Height   Width     score
1 58.7179 56.4663 0.4170000
2 54.6154 59.9279 0.3981695
3 58.7179 66.8510 0.2845042
4 63.8462 56.4663 0.4376807
R로 시작하는 이상치 탐지 입문

거리 점수 시각화

plot(Width ~ Height, cex = sqrt(score), data = furniture, pch = 20)

R로 시작하는 이상치 탐지 입문

연습해 봅시다!

R로 시작하는 이상치 탐지 입문

Preparing Video For Download...