AIMech AI

Local outlier factor

Algorithms AIMech:LocalOutlierFactor DRAFT
Aliases: LOF
An unsupervised local outlier-scoring procedure that compares each observation's inverse mean reachability distance with those of its tie-inclusive nearest neighbors and returns their mean density ratio.
Identity Notes & Concept Scope This record denotes the original fixed-neighborhood LOF procedure, with optional scale aggregation and versioned implementation conventions explicitly separated. It is distinct from neighbor-label voting, raw kth-distance ranking, thresholded NNDD or PDD, DBSCAN noise labels and OPTICS reachability ordering. The initial LOF review left OPTICS-OF as an unresolved related identity comparison. The subsequent AIMech:OPTICSOutlierFactor record documents its distinct self-inclusive convention; the two are not treated as aliases. Compared all 442 pinned AIO IDs, labels and scoped synonyms with all 511 preceding native IDs, names and aliases. No normalized identity collision was found. Fixed-string whole-word searches of both checkouts included ignored and hidden files, LOF, expanded names and both publication DOIs: 16 worktree and 17 main matches, comprising 13 distinct context windows at 33 locations, were read. They are pending discovery context and an unrelated BASIC-language LOF token in an ignored Pygments lexer. Semantic searches inspected 99 AIO name/synonym/definition rows and 70 native name/definition matches, reusing 85 and 67 unchanged previously read rows respectively. Thirteen annotated AIO CLASS nodes with outgoing edges and twenty contextual YAMLs were inspected or reused after unchanged-byte checks. This is a bounded corpus assessment, not absence from all ontologies.

Claims & Grounded Evidence

8 Claims
Mechanism #tie-inclusive-locality
For n reference observations and 1<=k<=n-1, k-distance(p) is the kth ordered distance to other observations, excluding p itself. N_k(p) contains every other observation whose distance is at most that boundary, including all ties, so its size can exceed k. The reference dataset and dissimilarity define locality; the procedure does not require labeled normal/outlier examples or an explicit clustering.
Mechanism #reachability-density-ratio
Define reach_k(p,o)=max(k-distance(o),d(p,o)), using the neighbor o's radius, not p's. Reachability is generally asymmetric. Local reachability density lrd_k(p) is the reciprocal of the mean reachability over o in N_k(p), and LOF_k(p) is the mean of lrd_k(o)/lrd_k(p) over that same neighborhood. These formulas require nonempty neighborhoods and positive finite mean reaches for the densities used. Reachability density has inverse-distance units; it is not a normalized probability density. LOF is a dimensionless relative score.
Limitation #relative-score-not-probability
A large score indicates lower reachability density relative to neighbors; it is neither an outlier probability nor a universal decision threshold. The paper's near-one bound assumes a closed two-hop neighborhood and bounded positive reachability variation. Scores can be below one: for D={0,1,3} under absolute distance and k=2, the scores are {11/12,6/5,11/12}. At k=1 they are {1,1,2}, reversing the center-versus-endpoint ordering. Two arbitrarily separated observations both score one at k=1; absolute isolation alone is not enough. These examples are exact curator calculations.
Limitation #ties-zeros-and-scale
Boundary ties are part of the original definition: D={0,2,4,5}, k=1 gives point 2 score 3/2 when both equidistant neighbors are retained, but score 1 if an exact-k implementation chooses only neighbor 0. Coincident observations can give zero mean reachability and undefined density ratios; the paper assumes no duplicates and mentions a distinct-coordinate alternative without making an additive regularizer part of core LOF. Multiplying every distance by a positive constant leaves the unregularized core score unchanged when defined; feature-specific rescaling can change neighborhoods and scores. For D={0,1,3}, k=2, reach(0,1)=2 exceeds d(0,1)=1, so the paper's informal k=2 raw-distance reduction is not generally implied by its self-excluded definitions.
Scope #neighborhood-scale-selection
Scores can vary nonmonotonically with k. The paper suggests choosing a lower and upper neighborhood size and ranking each point by its maximum LOF over that range; this is an optional multiscale ranking heuristic, distinct from a fixed-k score. Suggested lower bounds near 10 and common choices around 10-20 are empirical guidance, not mathematical validity constraints or universally optimal defaults. Small groups can appear ordinary relative to one another at some scales, so the chosen range affects which deviations are exposed.
Scope #versioned-implementation-conventions
The inspected scikit-learn 1.7.2-linked implementation uses a fixed neighbor count, excludes the indexed query for fitted training scores, and adds 1e-10 to mean reachability before inversion. It exposes negative LOF as negative_outlier_factor_; auto contamination chooses offset -1.5, while supplied contamination chooses a training-score percentile and labels scores strictly below it. These are implementation choices, not the paper's all-ties and unregularized definition or a universally validated 1.5 cutoff. Ties can prevent an exact requested outlier fraction. A fixed additive epsilon also prevents automatically transferring exact uniform-scale invariance.
Scope #novelty-query-distinction
With novelty=True, the inspected implementation scores new queries against stored training-neighbor radii and training densities; it does not insert the new query batch into reference neighborhoods. Supplying training points through score_samples can include each query itself as a neighbor, unlike the fitted training-score calculation. Novelty-query scores therefore need not equal negative_outlier_factor_ on the training set. This source-scoped extension does not redefine the original dataset-level score, and no library runtime or historical-code equivalence was tested.
Limitation #computation-and-evaluation-scope
After neighborhoods are available, computing densities and scores visits the retained neighbor incidences for each chosen k. Original all-boundary-ties neighborhoods can contain n-1 observations even for small k, so O(n*k) storage or linear score work requires a bounded-neighborhood assumption. All-pairs search can require quadratic distance evaluations; index performance depends on data and dimension. The paper's synthetic, sports and color-histogram examples and historical wall-clock timings are conditional demonstrations, not universal accuracy or speed guarantees. The sports results use selected features and neighborhood ranges with domain interpretation, not held-out probability calibration. No numerical performance advantage is curated.

⚠️ Curated Limitations & Negative Results

Artificial Intelligence Ontology (AIO) Grounding

Mapped AIO Classes
AIO Target Class Mapping Relation Mapping Rationale
AIO:UnsupervisedLearning
Unsupervised Learning
related_match LOF infers neighborhood-relative outlier scores from unlabeled observations, giving a related algorithm-to-task association with AIO:UnsupervisedLearning. The target is a MachineLearningTask; this link is neither exact equivalence nor a subclass assertion. The core score does not itself assign two classes, so BinaryClassification and its supervised ancestry are not selected. Clustering and OPTICS/DBSCAN organize clusters or reachability orderings, whereas LOF does not require a partition. All three AIO KnearestNeighbor classes specify label voting or response averaging, not local reachability ratios; RegressionAnalysis requires dependent/independent-variable relationships. DimensionalityReduction, DataPreparation and SelectionAndSamplingBias do not identify this scoring procedure. Native neighbor-ratio and distance-norm domain descriptions, PDD, supervised metric learning and density clustering have different outputs or neighborhood rules.

Evidence Sources & Primary Literature

3 Sources
Source ID Publication / Document Type / Access Reference & Checksum
breunig2000
Markus M. Breunig, Hans-Peter Kriegel, Raymond T. Ng, Jörg Sander
primary paper
full_text
ID: https://doi.org/10.1145/342009.335388
sha256:d6e378582bf7…
sklearn-lof
scikit-learn developers
official documentation
documentation
sha256:a05774d4db7d…
sklearn-neighbors
scikit-learn developers
official documentation
documentation
sha256:6686ee9f3f36…

Curation Provenance

Curator: Codex
Method: ai_assisted
Model: GPT-6
Created: 2026-10-12T08:52:07Z
Updated: 2026-10-12T09:12:41Z
Source File: data/curated/LocalOutlierFactor.yaml