Giới thiệu về Anomaly Detection bằng R
Alastair Rushworth
Data Scientist
Lớp của một cột
class(sat$V1)
"numeric"
Lớp của mọi cột
sapply(X = sat, FUN = class)
label V1 V2 V3 V4 V5 V6 high_low
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "character"
Mã hóa biến phân loại thành factor
sat$high_low <- as.factor(sat$high_low)class(sat$high_low)
"factor"
Huấn luyện isolation forest
sat_for <- iForest(sat[, -1], nt = 100)
Khoảng cách Gower đo khoảng cách giữa điểm có biến phân loại & số
library(cluster)
sat_dist <- daisy(sat[, -1], metric = "gower")
Truyền sat_dist vào lof
sat_lof <- lof(sat_dist, k = 10)
sat_distmat <- as.matrix(sat_dist)
range(sat_distmat)
0.0000000 0.8680774
Giới thiệu về Anomaly Detection bằng R