R로 시작하는 이상치 탐지 입문
Alastair Rushworth
Data Scientist
단일 열의 클래스
class(sat$V1)
"numeric"
모든 열의 클래스
sapply(X = sat, FUN = class)
label V1 V2 V3 V4 V5 V6 high_low
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "character"
범주형 특성을 factor로 인코딩
sat$high_low <- as.factor(sat$high_low)class(sat$high_low)
"factor"
Isolation Forest 학습
sat_for <- iForest(sat[, -1], nt = 100)
Gower 거리는 범주형·수치형 특성이 섞인 점들 간 거리를 측정합니다
library(cluster)
sat_dist <- daisy(sat[, -1], metric = "gower")
sat_dist를 lof에 전달
sat_lof <- lof(sat_dist, k = 10)
sat_distmat <- as.matrix(sat_dist)
range(sat_distmat)
0.0000000 0.8680774
R로 시작하는 이상치 탐지 입문