kNN-afstandsscore visualiseren

Introductie tot anomaliedetectie in R

Alastair Rushworth

Data Scientist

Features schalen standaardiseren

plot(Width ~ Height, data = furniture)

Introductie tot anomaliedetectie in R

Features standaardiseren

furniture_scaled <- scale(furniture)

plot(Width ~ Height, data = furniture_scaled)

Introductie tot anomaliedetectie in R

Afstandsscore maken en toevoegen

Afstandsmatrix

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

Score berekenen en toevoegen

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
Introductie tot anomaliedetectie in R

Afstandsscore visualiseren

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

Introductie tot anomaliedetectie in R

Laten we oefenen!

Introductie tot anomaliedetectie in R

Preparing Video For Download...