A Python Library for Graph Outlier Detection (Anomaly Detection)
Project description
PyGOD is a Python library for graph outlier detection (anomaly detection). This exciting yet challenging field has many key applications, e.g., detecting suspicious activities in social networks [1] and security systems [2].
PyGOD includes 10+ graph outlier detection algorithms. For consistency and accessibility, PyGOD is developed on top of PyTorch Geometric (PyG) and PyTorch, and follows the API design of PyOD. See examples below for detecting outliers with PyGOD in 5 lines!
PyGOD is featured for:
Unified APIs, detailed documentation, and interactive examples across various graph-based algorithms.
Comprehensive coverage of 10+ graph outlier detectors.
Full support of detections at multiple levels, such as node-, edge-, and graph-level tasks.
Scalable design for processing large graphs via mini-batch and sampling.
Streamline data processing with PyG–fully compatible with PyG data objects.
Outlier Detection Using PyGOD with 5 Lines of Code:
# train a dominant detector
from pygod.detector import DOMINANT
model = DOMINANT(num_layers=4, epoch=20) # hyperparameters can be set here
model.fit(train_data) # input data is a PyG data object
# get outlier scores on the training data (transductive setting)
score = model.decision_score_
# predict labels and scores on the testing data (inductive setting)
pred, score = model.predict(test_data, return_score=True)
Citing PyGOD:
Our software paper and benchmark paper are publicly available. If you use PyGOD or BOND in a scientific publication, we would appreciate citations to the following papers:
@article{liu2022pygod, title={PyGOD: A Python Library for Graph Outlier Detection}, author={Liu, Kay and Dou, Yingtong and Zhao, Yue and Ding, Xueying and Hu, Xiyang and Zhang, Ruitong and Ding, Kaize and Chen, Canyu and Peng, Hao and Shu, Kai and Chen, George H. and Jia, Zhihao and Yu, Philip S.}, journal={arXiv preprint arXiv:2204.12095}, year={2022} } @article{liu2022bond, title={Bond: Benchmarking unsupervised outlier node detection on static attributed graphs}, author={Liu, Kay and Dou, Yingtong and Zhao, Yue and Ding, Xueying and Hu, Xiyang and Zhang, Ruitong and Ding, Kaize and Chen, Canyu and Peng, Hao and Shu, Kai and Sun, Lichao and Li, Jundong and Chen, George H. and Jia, Zhihao and Yu, Philip S.}, journal={Advances in Neural Information Processing Systems}, volume={35}, pages={27021--27035}, year={2022} }
or:
Liu, K., Dou, Y., Zhao, Y., Ding, X., Hu, X., Zhang, R., Ding, K., Chen, C., Peng, H., Shu, K. and Chen, G.H., Jia, Z., and Yu, P.S. 2022. PyGOD: A Python Library for Graph Outlier Detection. arXiv preprint arXiv:2204.12095. Liu, K., Dou, Y., Zhao, Y., Ding, X., Hu, X., Zhang, R., Ding, K., Chen, C., Peng, H., Shu, K. and Sun, L., Li, J., Chen, G.H., Jia, Z., and Yu, P.S. 2022. Bond: Benchmarking unsupervised outlier node detection on static attributed graphs. Advances in Neural Information Processing Systems, 35, pp.27021-27035.
Installation
Note on PyG and PyTorch Installation: PyGOD depends on torch and torch_geometric (including its optional dependencies). To streamline the installation, PyGOD does NOT install these libraries for you. Please install them from the above links for running PyGOD:
torch>=2.0.0
torch_geometric>=2.3.0
It is recommended to use pip for installation. Please make sure the latest version is installed, as PyGOD is updated frequently:
pip install pygod # normal install
pip install --upgrade pygod # or update if needed
Alternatively, you could clone and run setup.py file:
git clone https://github.com/pygod-team/pygod.git
cd pygod
pip install .
Required Dependencies:
python>=3.8
numpy>=1.24.3
scikit-learn>=1.2.2
scipy>=1.10.1
networkx>=3.1
Quick Start for Outlier Detection with PyGOD
“A Blitz Introduction” demonstrates the basic API of PyGOD using the DOMINANT detector. It is noted that the API across all other algorithms are consistent/similar.
API Cheatsheet & Reference
Full API Reference: (https://docs.pygod.org). API cheatsheet for all detectors:
fit(data): Fit the detector with train data.
predict(data): Predict on test data (train data if not provided) using the fitted detector.
Key Attributes of a fitted detector:
decision_score_: The outlier scores of the input data. Outliers tend to have higher scores.
label_: The binary labels of the input data. 0 stands for inliers and 1 for outliers.
threshold_: The determined threshold for binary classification. Scores above the threshold are outliers.
Input of PyGOD: Please pass in a PyG Data object. See PyG data processing examples.
Implemented Algorithms
Abbr |
Year |
Backbone |
Sampling |
Ref |
---|---|---|---|---|
SCAN |
2007 |
Clustering |
No |
|
GAE |
2016 |
GNN+AE |
Yes |
|
Radar |
2017 |
MF |
No |
|
ANOMALOUS |
2018 |
MF |
No |
|
ONE |
2019 |
MF |
No |
|
DOMINANT |
2019 |
GNN+AE |
Yes |
|
DONE |
2020 |
MLP+AE |
Yes |
|
AdONE |
2020 |
MLP+AE |
Yes |
|
AnomalyDAE |
2020 |
GNN+AE |
Yes |
|
GAAN |
2020 |
GAN |
Yes |
|
DMGD |
2020 |
GNN+AE |
Yes |
|
OCGNN |
2021 |
GNN |
Yes |
|
CoLA |
2021 |
GNN+AE+SSL |
Yes |
|
GUIDE |
2021 |
GNN+AE |
Yes |
|
CONAD |
2022 |
GNN+AE+SSL |
Yes |
|
GADNR |
2024 |
GNN+AE |
Yes |
How to Contribute
You are welcome to contribute to this exciting project:
See contribution guide for more information.
PyGOD Team
PyGOD is a great team effort by researchers from UIC, IIT, BUAA, ASU, and CMU. Our core team members include:
Kay Liu (UIC), Yingtong Dou (UIC), Yue Zhao (CMU), Xueying Ding (CMU), Xiyang Hu (CMU), Ruitong Zhang (BUAA), Kaize Ding (ASU), Canyu Chen (IIT),
Reach out us by submitting an issue report or send an email to dev@pygod.org.
Reference
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pygod-1.1.0.tar.gz
.
File metadata
- Download URL: pygod-1.1.0.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9afd0db3a55b3ff20d24212cf85381db356456d6e21ba1f9687daf3619c5b36 |
|
MD5 | ec950de37ebcf09b652182bd68c63b29 |
|
BLAKE2b-256 | 4af50a9822e6a7931292e7738b3027e6dbab0e0f37f9364c4e28b11c05c1800b |
File details
Details for the file pygod-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: pygod-1.1.0-py3-none-any.whl
- Upload date:
- Size: 86.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58404d0dfc2bcc32951b226247587432b94fc63779a46d53799fd46625f858a2 |
|
MD5 | 0d0330bcb65294bbfe6236d886fcbc0a |
|
BLAKE2b-256 | 61f71a7d1f5e621475fb70d6d284fc3c432df6702bf59d86e8c61fa7d14e02d7 |