Part of a series on |

Machine learning and data mining |
---|

In anomaly detection, the **local outlier factor** (**LOF**) is an algorithm proposed by Markus M. Breunig, Hans-Peter Kriegel, Raymond T. Ng and Jörg Sander in 2000 for finding anomalous data points by measuring the local deviation of a given data point with respect to its neighbours.^{[1]}

LOF shares some concepts with DBSCAN and OPTICS such as the concepts of "core distance" and "reachability distance", which are used for local density estimation.^{[2]}

The local outlier factor is based on a concept of a local density, where locality is given by *k* nearest neighbors, whose distance is used to estimate the density. By comparing the local density of an object to the local densities of its neighbors, one can identify regions of similar density, and points that have a substantially lower density than their neighbors. These are considered to be outliers.

The local density is estimated by the typical distance at which a point can be "reached" from its neighbors. The definition of "reachability distance" used in LOF is an additional measure to produce more stable results within clusters. The "reachability distance" used by LOF has some subtle details that are often found incorrect in secondary sources, e.g., in the textbook of Ethem Alpaydin.^{[3]}

Let *k*-distance(*A*) be the distance of the object *A* to the *k*-th nearest neighbor. Note that the set of the *k* nearest neighbors includes all objects at this distance, which can in the case of a "tie" be more than *k* objects. We denote the set of *k* nearest neighbors as N_{k}(A).

This distance is used to define what is called *reachability distance*:

reachability-distance_{k}(*A*,*B*)=max{*k*-distance(*B*), d(*A*,*B*)}

In words, the *reachability distance* of an object *A* *from* *B* is the true distance of the two objects, but at least the *k*-distance of *B*. Objects that belong to the *k* nearest neighbors of *B* (the "core" of *B*, see DBSCAN cluster analysis) are considered to be equally distant. The reason for this distance is to get more stable results^{[citation needed]}. Note that this is not a distance in the mathematical definition, since it is not symmetric. (While it is a common mistake^{[4]} to always use the *k*-distance(A), this yields a slightly different method, referred to as Simplified-LOF^{[4]})

The *local reachability density* of an object *A* is defined by

lrd_{k}(A):=1/(_{B ∈ Nk(A)}reachability-distance_{k}(A, B)/|N_{k}(A)|)

which is the inverse of the average reachability distance of the object *A* *from* its neighbors. Note that it is not the average reachability of the neighbors from *A* (which by definition would be the *k*-distance(A)), but the distance at which *A* can be "reached" *from* its neighbors. With duplicate points, this value can become infinite.

The local reachability densities are then compared with those of the neighbors using

LOF_{k}(A):=_{B ∈ Nk(A)}_{k}(B)/lrd_{k}(A)/|N_{k}(A)|
= _{B ∈ Nk(A)}lrd_{k}(B)/|N_{k}(A)| · lrd_{k}(A)

which is the *average local reachability density of the neighbors* divided by the object's own local reachability density. A value of approximately 1 indicates that the object is comparable to its neighbors (and thus not an outlier). A value below 1 indicates a denser region (which would be an inlier), while values significantly larger than 1 indicate outliers.

LOF(k) ~ 1 means **Similar density as neighbors,**

LOF(k) < 1 means **Higher density than neighbors (Inlier),**

LOF(k) > 1 means **Lower density than neighbors (Outlier)**

Due to the local approach, LOF is able to identify outliers in a data set that would not be outliers in another area of the data set. For example, a point at a "small" distance to a very dense cluster is an outlier, while a point within a sparse cluster might exhibit similar distances to its neighbors.

While the geometric intuition of LOF is only applicable to low-dimensional vector spaces, the algorithm can be applied in any context a dissimilarity function can be defined. It has experimentally been shown to work very well in numerous setups, often outperforming the competitors, for example in network intrusion detection^{[5]} and on processed classification benchmark data.^{[6]}

The LOF family of methods can be easily generalized and then applied to various other problems, such as detecting outliers in geographic data, video streams or authorship networks.^{[4]}

The resulting values are quotient-values and hard to interpret. A value of 1 or even less indicates a clear inlier, but there is no clear rule for when a point is an outlier. In one data set, a value of 1.1 may already be an outlier, in another dataset and parameterization (with strong local fluctuations) a value of 2 could still be an inlier. These differences can also occur within a dataset due to the locality of the method. There exist extensions of LOF that try to improve over LOF in these aspects:

*Feature Bagging for Outlier Detection*^{[7]}runs LOF on multiple projections and combines the results for improved detection qualities in high dimensions. This is the first ensemble learning approach to outlier detection, for other variants see ref.^{[8]}*Local Outlier Probability*(LoOP)^{[9]}is a method derived from LOF but using inexpensive local statistics to become less sensitive to the choice of the parameter*k*. In addition, the resulting values are scaled to a value range of [0:1].*Interpreting and Unifying Outlier Scores*^{[10]}proposes a normalization of the LOF outlier scores to the interval [0:1] using statistical scaling to increase usability and can be seen an improved version of the LoOP ideas.*On Evaluation of Outlier Rankings and Outlier Scores*^{[11]}proposes methods for measuring similarity and diversity of methods for building advanced outlier detection ensembles using LOF variants and other algorithms and improving on the Feature Bagging approach discussed above.*Local outlier detection reconsidered: a generalized view on locality with applications to spatial, video, and network outlier detection*^{[4]}discusses the general pattern in various local outlier detection methods (including, e.g., LOF, a simplified version of LOF and LoOP) and abstracts from this into a general framework. This framework is then applied, e.g., to detecting outliers in geographic data, video streams and authorship networks.

**^**.mw-parser-output cite.citation{font-style:inherit}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .id-lock-free a,.mw-parser-output .citation .cs1-lock-free a{background:linear-gradient(transparent,transparent),url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited a,.mw-parser-output .id-lock-registration a,.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:linear-gradient(transparent,transparent),url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription a,.mw-parser-output .citation .cs1-lock-subscription a{background:linear-gradient(transparent,transparent),url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration{color:#555}.mw-parser-output .cs1-subscription span,.mw-parser-output .cs1-registration span{border-bottom:1px dotted;cursor:help}.mw-parser-output .cs1-ws-icon a{background:linear-gradient(transparent,transparent),url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}.mw-parser-output code.cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;font-size:100%}.mw-parser-output .cs1-visible-error{font-size:100%}.mw-parser-output .cs1-maint{display:none;color:#33aa33;margin-left:0.3em}.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left,.mw-parser-output .cs1-kern-wl-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right,.mw-parser-output .cs1-kern-wl-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit} Breunig, M. M.; Kriegel, H.-P.; Ng, R. T.; Sander, J. (2000).*LOF: Identifying Density-based Local Outliers*(PDF).*Proceedings of the 2000 ACM SIGMOD International Conference on Management of Data*. SIGMOD. pp. 93–104. doi:10.1145/335191.335388. ISBN 1-58113-217-4.**^**Breunig, M. M.; Kriegel, H.-P.; Ng, R. T.; Sander, J. R. (1999). "OPTICS-OF: Identifying Local Outliers" (PDF). *Principles of Data Mining and Knowledge Discovery*. Lecture Notes in Computer Science.**1704**. p. 262. doi:10.1007/978-3-540-48247-5_28. ISBN 978-3-540-66490-1.**^**Alpaydin, Ethem (2020). *Introduction to machine learning*(Fourth ed.). Cambridge, Massachusetts. ISBN 978-0-262-04379-3. OCLC 1108782604.- ^
^{a}^{b}^{c}^{d}Schubert, E.; Zimek, A.; Kriegel, H. -P. (2012). "Local outlier detection reconsidered: A generalized view on locality with applications to spatial, video, and network outlier detection". *Data Mining and Knowledge Discovery*.**28**: 190–237. doi:10.1007/s10618-012-0300-z. S2CID 19036098. **^**Lazarevic, A.; Ozgur, A.; Ertoz, L.; Srivastava, J.; Kumar, V. (2003). "A comparative study of anomaly detection schemes in network intrusion detection" (PDF). *Proc. 3rd SIAM International Conference on Data Mining*: 25–36. Archived from the original (PDF) on 2013-07-17. Retrieved 2010-05-14.CS1 maint: uses authors parameter (link)**^**Campos, Guilherme O.; Zimek, Arthur; Sander, Jörg; Campello, Ricardo J. G. B.; Micenková, Barbora; Schubert, Erich; Assent, Ira; Houle, Michael E. (2016). "On the evaluation of unsupervised outlier detection: measures, datasets, and an empirical study". *Data Mining and Knowledge Discovery*.**30**(4): 891–927. doi:10.1007/s10618-015-0444-8. ISSN 1384-5810. S2CID 1952214.**^**Lazarevic, A.; Kumar, V. (2005). "Feature bagging for outlier detection". *Proc. 11th ACM SIGKDD International Conference on Knowledge Discovery in Data Mining*: 157–166. doi:10.1145/1081870.1081891. ISBN 159593135X. S2CID 2054204.**^**Zimek, A.; Campello, R. J. G. B.; Sander, J. R. (2014). "Ensembles for unsupervised outlier detection". *ACM SIGKDD Explorations Newsletter*.**15**: 11–22. doi:10.1145/2594473.2594476. S2CID 8065347.**^**Kriegel, H.-P.; Kröger, P.; Schubert, E.; Zimek, A. (2009). *LoOP: Local Outlier Probabilities*(PDF).*Proceedings of the 18th ACM Conference on Information and Knowledge Management*. CIKM '09. pp. 1649–1652. doi:10.1145/1645953.1646195. ISBN 978-1-60558-512-3.**^**Kriegel, H. P.; Kröger, P.; Schubert, E.; Zimek, A. (2011). *Interpreting and Unifying Outlier Scores*. Proceedings of the 2011 SIAM International Conference on Data Mining. pp. 13–24. CiteSeerX 10.1.1.232.2719. doi:10.1137/1.9781611972818.2. ISBN 978-0-89871-992-5.**^**Schubert, E.; Wojdanowski, R.; Zimek, A.; Kriegel, H. P. (2012). *On Evaluation of Outlier Rankings and Outlier Scores*. Proceedings of the 2012 SIAM International Conference on Data Mining. pp. 1047–1058. CiteSeerX 10.1.1.300.7205. doi:10.1137/1.9781611972825.90. ISBN 978-1-61197-232-0.