Hashing for Structure-Based Anomaly Detection

Filippo Leveni, Luca Magri, Cesare Alippi, Giacomo Boracchi · DOI · OpenReview

Introduction

Traditional anomaly detection often fails when data follows complex geometric structures rather than simple density clusters. This paper introduces RuzHash-iForest, a novel framework that identifies structural anomalies with unprecedented efficiency. By employing a specialized Locality Sensitive Hashing (LSH) scheme, the method achieves a 35% to 70% speedup over existing state-of-the-art structural detection techniques while maintaining or improving accuracy.

The Challenge of Structural Anomalies

Most algorithms assume anomalies reside in low-density regions. However, in many domains, "normal" data adheres to specific manifolds or parametric models (e.g., lines, curves, or homographies). A point might be in a dense region but still be an anomaly if it violates the underlying geometric structure.

To solve this, data is mapped into a Preference Space $\mathcal{P}$. In this space, each point is represented by its "preference" for various candidate models. Points that fit common structures cluster together, while structural anomalies become isolated.

The structural anomaly detection pipeline: (a) input data with geometric structures, (b) mapping to preference space, and (c) resulting anomaly scores.

Methodology: RuzHash-iForest

The core innovation is the integration of RuzHash into an Isolation Forest framework.

  1. Preference Embedding: Input data $X$ is transformed into high-dimensional vectors in $[0, 1]^m$, where each dimension represents the fit to a sampled model.
  2. RuzHash LSH: Calculating exact distances (like Ruzicka or Jaccard) in high dimensions is computationally prohibitive. RuzHash approximates these distances by binarizing preference vectors against random thresholds.
  3. Efficient Branching: Unlike previous methods that rely on expensive Voronoi tessellations, RuzHash allows for high branching factors without a performance hit. This results in shallower trees and faster inference.
RuzHash facilitates multi-way node splitting in isolation trees, efficiently grouping points with similar structural preferences.

Results and Impact

Evaluations on synthetic 2D datasets and the real-world AdelaideRMF computer vision dataset demonstrate the method's superiority:

  • Speed: The continuous RHF variant is 70% faster than the previous leader, PI-Forest.
  • Scalability: Test time decreases logarithmically with the branching factor, making it highly suitable for large-scale applications.
  • Robustness: The method remains stable across different branching factors, a significant improvement over prior Voronoi-based approaches.

Conclusion

RuzHash-iForest bridges the gap between the high accuracy of structural anomaly detection and the need for computational efficiency. By generalizing MinHash to continuous preference spaces, the authors provide a scalable solution for detecting complex anomalies in structured data. Future work may explore extending this LSH approach to other distance metrics tailored for specific data distributions.

Summary updated

BibTeX
@misc{leveni2023hashing,
  author = {Filippo Leveni and Luca Magri and Cesare Alippi and Giacomo Boracchi},
  title = {{Hashing for Structure-Based Anomaly Detection}},
  year = {2023},
  eprint = {2505.10873},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.10873},
}
Figure