This repository contains the PyTorch implementation of the NeurIPS 2023 New Frontiers in Graph Learning (GLFrontiers) workshop paper "GAD-EBM: Graph Anomaly Detection using Energy-Based Models" by Amit Roy, Juan Shu, Olivier Elshocht, Jeroen Smeets, Ruqi Zhang and Pan Li.
Graph Anomaly Detection (GAD) is essential in fields ranging from network security, and bioinformatics to finance. Previous works often adopt auto-encoders to compute reconstruction errors for anomaly detection: anomalies are hard to be reconstructed. In this work, we revisit the first principle for anomaly detection, i.e., the Neyman-Pearson rule, where the optimal anomaly detector is based on the likelihood of a data point given the normal distribution of data. However, in practice, the distribution is often unknown and the estimation of the distribution of graph-structured data may be hard. Moreover, the likelihood computation of a graph-structured data point may be challenging as well. In this paper, we propose a novel approach GAD-EBM that can estimate the distribution of graphs and compute likelihoods efficiently by using Energy-Based Models (EBMs) over graphs. GAD-EBM approaches the likelihood of a rooted subgraph of node
Exapmle of a neighborhood state-space graph
--dataset Anomaly detection dataset (default: disney)
--perturb_percent Percentages of edges to be added/deleted (default: 0.05)
--seed Random Number Seed (default: 42)
--nb_epochs Number of epochs (default: 200)
--hidden_dim Hidden Dimension Size (default: 16)
--lr Learning Rate (default: 0.01)
--l2_coef Regularization coefficient (default: 0.01)
--drop_edge Drop Edge Flag (default: True)
--add_edge Add Edge Flag (default: False)
--self_loop Self-loop flag (default: True)
--preprocess_feat Preprocess Features (default: True)
--GNN_name GNN Encoder (default: GCN)
--num_neigh Number of Neighbors in the State-Space Graph (default: 1)
Create Conda Environment
conda create --name GAD-EBM
conda activate GAD-EBM
Install pytorch:
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
Install pytorch geometric:
pip install pyg-lib torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.13.0+cu117.html
Install requirements.txt
conda install --file requirements.txt
Run the python notebook with appropriate parameter changes.
To run GAD-EBM on the DGraph dataset, please download the DGraphFin dataset file 'DGraphFin.zip' from the website 'https://dgraph.xinye.com/introduction' and place it under the directory './dataset/raw'.
Dataset Description
Benchmark Anomaly Detection Results
Likelihood comparison
Running Time Comparison
If you find our paper and repo useful, please cite our paper:
@inproceedings{roy2023gad,
title={GAD-EBM: Graph Anomaly Detection using Energy-Based Models},
author={Roy, Amit and Shu, Juan and Elshocht, Olivier and Smeets, Jeroen and Zhang, Ruqi and Li, Pan},
booktitle={NeurIPS 2023 Workshop: New Frontiers in Graph Learning},
year={2023}
}