Abstract
This paper introduces the Adaptive Local Outlier Factor (AlynLOF), a novel streaming anomaly detection algorithm that integrates the Granularity k-Nearest Neighbor (GkNN) method. Unlike traditional LOF and recent variants like EiLOF, which depend on fixed, user-defined parameters, GkNN automatically computes a single global optimal k by analyzing the granularity structure of the current data window. This allows the algorithm to adapt autonomously to evolving data distributions. A key advantage of AlynLOF is its constant-memory design; it retains a fixed buffer of only 100 relevant data points, using a Kneedle algorithm and weight mechanism to discard outdated or anomalous instances, thereby ensuring scalability. Extensive empirical validation across 17 benchmark datasets compares AlynLOF against 9 state-of-the-art algorithms. The results demonstrate that AlynLOF achieves the highest average ROC AUC of 0.7780 and the best average rank based on Skillings-Mack which is 9.6, significantly outperforming competitors such as LODA (rank 6.2) and EiLOF (rank 6.0). Pairwise statistical tests using Wilcoxon and Holm correction confirm that AlynLOF achieves superior accuracy (p < 0.05) against eight baseline methods, establishing it as a robust solution for real-time anomaly detection in memory-constrained environments.