Improved anomaly detection by using the attention-based isolation forest with trainable scoring function
This paper proposes a novel anomaly detection model, called Attention-Based Isolation Forest with trainable Scoring Function (ABIF-SF). ABIF-SF enhances the original isolation forest algorithm by incorporating attention weights determined by scoring functions whose parameters are trained using gradient descent. The attention weights indicate the relevance of each data instance to the anomaly assessment task for each tree in the isolation forest. Two scoring functions are explored – scaled dot product and additive attention. Numerical experiments on real-world datasets demonstrate that ABIF-SF achieves better anomaly detection performance compared to isolation forest and attention-based isolation forest with the contamination model. The proposed method simplifies the computation of attention weights by using scoring functions and hinge loss optimization. The code implementation of ABIF-SF has been made publicly available for further research and benchmarking. Overall, the incorporation of trainable scoring functions to compute context-aware attention weights improves isolation forests for anomaly detection tasks.