Skip to content
StackDecode
AI & ML Atlas
Machine LearningalgorithmAnimated walkthrough

Local Outlier Factor (LOF)

Flags points whose neighbourhood is much sparser than their neighbours'.

The idea

A point in a loose cluster is fine; a point just as far from its neighbours in a very tight cluster is not. LOF compares a point's local density with the densities around its k nearest neighbours. A ratio near 1 means similar density; well above 1 means an outlier.

LOF(p) = mean(lrd(neighbour)) / lrd(p)

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Find each point's k nearest neighbours.
  2. 2Compute the reachability distance and the local density.
  3. 3Compare each point's density with its neighbours' average.
  4. 4The ratio is the LOF score; large values are outliers.

LOF(p) = mean(lrd(neighbour)) / lrd(p)

1/4

Step by step

  1. 1Find each point's k nearest neighbours.
  2. 2Compute the reachability distance and the local density.
  3. 3Compare each point's density with its neighbours' average.
  4. 4The ratio is the LOF score; large values are outliers.

Where it is used

Anomaly detection in data with clusters of different densities.

Watch out for

Sensitive to k, and costly on large data.

Related