The local outlier factor (LOF)

Introduction to Anomaly Detection in R

Alastair Rushworth

Data Scientist

Postmortem of kNN distance

Global versus local anomalies

Introduction to Anomaly Detection in R

Calculating LOF

Obtain LOF for furniture data

library(dbscan)
furniture_lof <- lof(scale(furniture), k = 5)

View the scores

furniture_lof[1:10]
[1] 1.0649669 1.1071205 0.9980290 1.0392385 0.9725305
[6] 1.1933199 1.3210459 1.1409659 1.0613144 1.0805445
Introduction to Anomaly Detection in R

Interpreting LOF

LOF is a ratio of densities

  • LOF $> 1$ more likely to be anomalous
  • LOF $\le 1$ less likely to be anomalous

 

Large LOF values indicate more isolated points

Introduction to Anomaly Detection in R

Visualizing LOF

furniture$score_lof <- furniture_lof

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

Introduction to Anomaly Detection in R

Let's practice!

Introduction to Anomaly Detection in R

Preparing Video For Download...