Local outlier Factor (LoF) is another density based approach to identify outliers in a dataset. The LoF is applicable to identify outliers in a dataset, which has a mixture of data distributions.

The above figure shows two different distributions, a dense cluster of points and a sparse distribution of points. In such datasets, for each specific distribution within a dataset, we should perform outlier detection locally, i.e., points within one distribution should not affect outlier detection in another cluster. The LoF algorithm follows the same intuition and calculates anomaly score for each point within a distribution as:- For each data point , let represent distance of point to its neighbor, and represent set of points within
- Compute reachability distance for each data point, as
- Compute Average reachability distance of data point as
- In the final step, LOF score for each point, is calculated as:

To find the best value of , it is always good to follow ensemble approach, i.e., use a range of values to calculate LOF scores and then use a specific method to combine the outlier scores.

References:

- Book: Outlier Analysis by Charu Aggarwal
- Wikipedia
- Google Images