{"id":22229783,"url":"https://github.com/graph-com/gad-ebm","last_synced_at":"2025-07-07T13:35:55.121Z","repository":{"id":204333766,"uuid":"711598224","full_name":"Graph-COM/GAD-EBM","owner":"Graph-COM","description":"[NeurIPS  2023 : GLFRONTIERS Workshop] GAD-EBM : Graph Anomaly Detection using Energy-Based Models","archived":false,"fork":false,"pushed_at":"2024-09-15T20:12:03.000Z","size":1449,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-03T01:12:41.944Z","etag":null,"topics":["energy-based-model","glfrontiers","graph-anomaly-detection","neurips-2023"],"latest_commit_sha":null,"homepage":"https://openreview.net/forum?id=I5hf3opvgK","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Graph-COM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-29T18:44:58.000Z","updated_at":"2024-10-29T06:34:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"23dadb55-5ed7-4a71-8604-b98e995095ab","html_url":"https://github.com/Graph-COM/GAD-EBM","commit_stats":null,"previous_names":["graph-com/gad-ebm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FGAD-EBM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FGAD-EBM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FGAD-EBM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FGAD-EBM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Graph-COM","download_url":"https://codeload.github.com/Graph-COM/GAD-EBM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236317041,"owners_count":19129544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["energy-based-model","glfrontiers","graph-anomaly-detection","neurips-2023"],"created_at":"2024-12-03T01:12:23.776Z","updated_at":"2025-01-30T08:16:19.595Z","avatar_url":"https://github.com/Graph-COM.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eGAD-EBM: Graph Anomaly Detection\u003cbr\u003e using Energy-Based Models\u003c/h1\u003e\n\nThis 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](https://amitroy7781.github.io/), Juan Shu, Olivier Elshocht, Jeroen Smeets, Ruqi Zhang and Pan Li.\n\n## Abstract\n\u003cp align=\"justify\"\u003e\nGraph 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 $v$, and further can leverage the likelihood to accurately identify whether node $v$ is anomalous or not. Traditional score matching for training EBMs may not be used to apply EBMs that model the distribution of graphs because of complicated discreteness and multi-modality of graph data. We propose a Subgraph Score Matching (SSM) approach, which is specifically designed for graph data based on a novel framework of neighborhood state-space graphs. Experimentation conducted on six real-world datasets validates the effectiveness and efficiency of GAD-EBM and the source code for GAD-EBM is openly available. \n\u003c/p\u003e\n\n    \n\n\n## Neighborhood State-Space Graph\n\n\u003cimg src=\"neighborhood_state_space_graph.png\" width=\"1000\" height=\"500\"\u003e \u003cbr\u003e\n\u003cp align=\"justify\"\u003e \n\u003cb\u003eExapmle of a neighborhood state-space graph\u003c/b\u003e\n\u003c/p\u003e\n\n\n## Main Parameters\n\n```\n--dataset                    Anomaly detection dataset (default: disney)\n--perturb_percent            Percentages of edges to be added/deleted (default: 0.05)\n--seed                       Random Number Seed (default: 42)\n--nb_epochs                  Number of epochs (default: 200)\n--hidden_dim                 Hidden Dimension Size (default: 16)\n--lr                         Learning Rate (default: 0.01)\n--l2_coef                    Regularization coefficient (default: 0.01)\n--drop_edge                  Drop Edge Flag (default: True)\n--add_edge                   Add Edge Flag (default: False)\n--self_loop                  Self-loop flag (default: True)\n--preprocess_feat            Preprocess Features (default: True)\n--GNN_name                   GNN Encoder (default: GCN)\n--num_neigh                  Number of Neighbors in the State-Space Graph (default: 1)                 \n```\n\n\n\n## Environment Setup\n\nCreate Conda Environment\n```\nconda create --name GAD-EBM\nconda activate GAD-EBM\n```\n\nInstall pytorch:\n```\nconda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia\n\n```\nInstall pytorch geometric:\n```\npip 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\n\n```\n\nInstall requirements.txt\n```\nconda install --file requirements.txt\n```\n\n## Basic Usage\n\nRun the python notebook with appropriate parameter changes. \n\nTo 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'.\n\n## Experimental Results\n\n**Dataset Description**\n\n\u003cimg src=\"dataset_description.png\" width=\"1000\"\u003e\n\n**Benchmark Anomaly Detection Results**\n\n\u003cimg src=\"benchmark_results.png\" width=\"1000\"\u003e\n\n**Likelihood comparison**\n\n\u003cimg src=\"likelihood_change.png\" width=\"1000\"\u003e\n\n**Running Time Comparison**\n\n\u003cimg src=\"running_time_analysis.png\" width=\"1000\"\u003e \n\n\n\n\n## Cite\n\nIf you find our paper and repo useful, please cite our paper:\n\n```bibtex\n@inproceedings{roy2023gad,\n  title={GAD-EBM: Graph Anomaly Detection using Energy-Based Models},\n  author={Roy, Amit and Shu, Juan and Elshocht, Olivier and Smeets, Jeroen and Zhang, Ruqi and Li, Pan},\n  booktitle={NeurIPS 2023 Workshop: New Frontiers in Graph Learning},\n  year={2023}\n}\n```\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=Graph-COM/GAD-EBM\u0026type=Date)](https://star-history.com/#Graph-COM/GAD-EBM\u0026Date)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraph-com%2Fgad-ebm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraph-com%2Fgad-ebm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraph-com%2Fgad-ebm/lists"}