Package: pygod
PyGOD is aPython libraryforgraph 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 includes10+graph outlier detection algorithms.
For consistency and accessibility, PyGOD is developed on top ofPyTorch Geometric (PyG)andPyTorch, and follows the API design ofPyOD.
See examples below for detecting outliers with PyGOD in 5 lines!PyGOD is featured for:Unified APIs, detailed documentation, and interactive examplesacross various graph-based algorithms.Comprehensive coverageof 10+ graph outlier detectors.Full support of detections at multiple levels, such as node-, edge-, and graph-level tasks.Scalable design for processing large graphsvia 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 detectorfrompygod.detectorimportDOMINANTmodel=DOMINANT(num_layers=4,epoch=20)# hyperparameters can be set heremodel.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:Oursoftware paperandbenchmark paperare 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.InstallationNote on PyG and PyTorch Installation:
PyGOD depends ontorchandtorch_geometric (including its optional dependencies).
To streamline the installation, PyGOD doesNOTinstall these libraries for you.
Please install them from the above links for running PyGOD:torch>=2.0.0torch_geometric>=2.3.0It is recommended to usepipfor installation.
Please make surethe latest versionis installed, as PyGOD is updated frequently:pipinstallpygod# normal installpipinstall--upgradepygod# or update if neededAlternatively, you could clone and run setup.py file:gitclonehttps://github.com/pygod-team/pygod.gitcdpygodpipinstall.Required Dependencies:python>=3.8numpy>=1.24.3scikit-learn>=1.2.2scipy>=1.10.1networkx>=3.1Quick 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 & ReferenceFull 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 aPyG Data object.
SeePyG data processing examples.Implemented AlgorithmsAbbrYearBackboneSamplingRefSCAN2007ClusteringNo[3]GAE2016GNN+AEYes[4]Radar2017MFNo[5]ANOMALOUS2018MFNo[6]ONE2019MFNo[7]DOMINANT2019GNN+AEYes[8]DONE2020MLP+AEYes[9]AdONE2020MLP+AEYes[9]AnomalyDAE2020GNN+AEYes[10]GAAN2020GANYes[11]DMGD2020GNN+AEYes[12]OCGNN2021GNNYes[13]CoLA2021GNN+AE+SSLYes[14]GUIDE2021GNN+AEYes[15]CONAD2022GNN+AE+SSLYes[16]GADNR2024GNN+AEYes[17]How to ContributeYou are welcome to contribute to this exciting project:Seecontribution guidefor more information.PyGOD TeamPyGOD 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 todev@pygod.org.Reference[1]Dou, Y., Liu, Z., Sun, L., Deng, Y., Peng, H. and Yu, P.S., 2020, October. Enhancing graph neural network-based fraud detectors against camouflaged fraudsters. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management (CIKM).[2]Cai, L., Chen, Z., Luo, C., Gui, J., Ni, J., Li, D. and Chen, H., 2021, October. Structural temporal graph neural networks for anomaly detection in dynamic graphs. In Proceedings of the 30th ACM International Conference on Information & Knowledge Management (CIKM).[3]Xu, X., Yuruk, N., Feng, Z. and Schweiger, T.A., 2007, August. Scan: a structural clustering algorithm for networks. In Proceedings of the 13th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD).[4]Kipf, T.N. and Welling, M., 2016. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308.[5]Li, J., Dani, H., Hu, X. and Liu, H., 2017, August. Radar: Residual Analysis for Anomaly Detection in Attributed Networks. In Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence (IJCAI).[6]Peng, Z., Luo, M., Li, J., Liu, H. and Zheng, Q., 2018, July. ANOMALOUS: A Joint Modeling Approach for Anomaly Detection on Attributed Networks. In Proceedings of the Twenty-Seventh International Joint Conference on Artificial Intelligence (IJCAI).[7]Bandyopadhyay, S., Lokesh, N. and Murty, M.N., 2019, July. Outlier aware network embedding for attributed networks. In Proceedings of the AAAI conference on artificial intelligence (AAAI).[8]Ding, K., Li, J., Bhanushali, R. and Liu, H., 2019, May. Deep anomaly detection on attributed networks. In Proceedings of the SIAM International Conference on Data Mining (SDM).[9](1,2)Bandyopadhyay, S., Vivek, S.V. and Murty, M.N., 2020, January. Outlier resistant unsupervised deep architectures for attributed network embedding. In Proceedings of the International Conference on Web Search and Data Mining (WSDM).[10]Fan, H., Zhang, F. and Li, Z., 2020, May. AnomalyDAE: Dual autoencoder for anomaly detection on attributed networks. In Proceedings of the IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP).[11]Chen, Z., Liu, B., Wang, M., Dai, P., Lv, J. and Bo, L., 2020, October. Generative adversarial attributed network anomaly detection. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management (CIKM).[12]Bandyopadhyay, S., Vishal Vivek, S. and Murty, M.N., 2020. Integrating network embedding and community outlier detection via multiclass graph description. Frontiers in Artificial Intelligence and Applications, (FAIA).[13]Wang, X., Jin, B., Du, Y., Cui, P., Tan, Y. and Yang, Y., 2021. One-class graph neural networks for anomaly detection in attributed networks. Neural computing and applications.[14]Liu, Y., Li, Z., Pan, S., Gong, C., Zhou, C. and Karypis, G., 2021. Anomaly detection on attributed networks via contrastive self-supervised learning. IEEE transactions on neural networks and learning systems (TNNLS).[15]Yuan, X., Zhou, N., Yu, S., Huang, H., Chen, Z. and Xia, F., 2021, December. Higher-order Structure Based Anomaly Detection on Attributed Networks. In 2021 IEEE International Conference on Big Data (Big Data).[16]Xu, Z., Huang, X., Zhao, Y., Dong, Y., and Li, J., 2022. Contrastive Attributed Network Anomaly Detection with Data Augmentation. In Proceedings of the 26th Pacific-Asia Conference on Knowledge Discovery and Data Mining (PAKDD).[17]Roy, A., Shu, J., Li, J., Yang, C., Elshocht, O., Smeets, J. and Li, P., 2024. GAD-NR: Graph Anomaly Detection via Neighborhood Reconstruction. In Proceedings of the 17th ACM International Conference on Web Search and Data Mining (WSDM).