Introductie tot anomaliedetectie in R
Alastair Rushworth
Data Scientist
Klasse van één kolom
class(sat$V1)
"numeric"
Klasse van alle kolommen
sapply(X = sat, FUN = class)
label V1 V2 V3 V4 V5 V6 high_low
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "character"
Categorische features als factor encoderen
sat$high_low <- as.factor(sat$high_low)class(sat$high_low)
"factor"
Isolation forest trainen
sat_for <- iForest(sat[, -1], nt = 100)
Gower-afstand meet afstand tussen punten met categorische en numerieke features
library(cluster)
sat_dist <- daisy(sat[, -1], metric = "gower")
Geef sat_dist door aan lof
sat_lof <- lof(sat_dist, k = 10)
sat_distmat <- as.matrix(sat_dist)
range(sat_distmat)
0.0000000 0.8680774
Introductie tot anomaliedetectie in R