Coder Social home page Coder Social logo

ekth0r / pygod Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pygod-team/pygod

0.0 0.0 0.0 1.01 MB

A Python Library for Graph Outlier Detection (Anomaly Detection)

Home Page: https://pygod.org

License: BSD 2-Clause "Simplified" License

Python 100.00%

pygod's Introduction

PyGOD Logo

PyPI version Documentation status GitHub stars GitHub forks testing Coverage Status License

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 more than 10 latest graph-based detection algorithms, such as DOMINANT (SDM'19) and GUIDE (BigData'21). For consistently 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 under actively developed and will be updated frequently! Please star, watch, and fork.

PyGOD is featured for:

  • Unified APIs, detailed documentation, and interactive examples across various graph-based algorithms.
  • Comprehensive coverage of more than 10 latest graph outlier detectors.
  • Full support of detections at multiple levels, such as node-, edge-, and graph-level tasks (WIP).
  • 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.models import DOMINANT

model = DOMINANT()  # hyperparameters can be set here
model.fit(data)  # data is a Pytorch Geometric data object

# get outlier scores on the input data
outlier_scores = model.decision_scores # raw outlier scores on the input data

# predict on the new data
outlier_scores = model.decision_function(test_data) # raw outlier scores on the input data  # predict raw outlier scores on test

Citing PyGOD (to be announced soon):

PyGOD paper will be available on arxiv soon. If you use PyGOD in a scientific publication, we would appreciate citations to the following paper (to be announced):

@article{tba,
  author  = {tba},
  title   = {PyGOD: A Comprehensive Python Library for Graph Outlier Detection},
  journal = {tba},
  year    = {2022},
}

or:

tba, 2022. PyGOD: A Comprehensive Python Library for Graph Outlier Detection. tba.

Installation

It is recommended to use pip or conda (wip) 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.6 +
  • argparse>=1.4.0
  • numpy>=1.19.4
  • scikit-learn>=0.22.1
  • scipy>=1.5.2
  • pandas>=1.1.3
  • setuptools>=50.3.1.post20201107

Note on PyG and PyTorch Installation: PyGOD depends on PyTorch Geometric (PyG), PyTorch, and networkx. To streamline the installation, PyGOD does NOT install these libraries for you. Please install them from the above links for running PyGOD:

  • torch>=1.10
  • pytorch_geometric>=2.0.3
  • networkx>=2.6.3

API Cheatsheet & Reference

Full API Reference: (https://docs.pygod.org). API cheatsheet for all detectors:

  • fit(X): Fit detector.
  • decision_function(G): Predict raw anomaly score of PyG data G using the fitted detector.
  • predict(G): Predict if nodes in PyG data G is an outlier or not using the fitted detector.
  • predict_proba(G): Predict the probability of nodes in PyG data G being outlier using the fitted detector.
  • predict_confidence(G): Predict the model's node-wise confidence (available in predict and predict_proba) [3].

Key Attributes of a fitted model:

  • decision_scores_: The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores.
  • labels_: The binary labels of the training data. 0 stands for inliers and 1 for outliers/anomalies.

Implemented Algorithms

PyGOD toolkit consists of two major functional groups:

(i) Node-level detection :

Type Backbone Abbr Algorithm Year Ref
Unsupervised MLP MLPAE Anomaly Detection Using Autoencoders with Nonlinear Dimensionality Reduction 2014 [4]
Unsupervised GNN GCNAE Variational Graph Auto-Encoders 2016 [5]
Unsupervised MF ONE Outlier aware network embedding for attributed networks 2019 [6]
Unsupervised GNN DOMINANT Deep anomaly detection on attributed networks 2019 [7]
Unsupervised GNN DONE Outlier Resistant Unsupervised Deep Architectures for Attributed Network Embedding 2020 [8]
Unsupervised GNN AdONE Outlier Resistant Unsupervised Deep Architectures for Attributed Network Embedding 2020 [8]
Unsupervised GNN AnomalyDAE AnomalyDAE: Dual autoencoder for anomaly detection on attributed networks 2020 [9]
Unsupervised GAN GAAN Generative Adversarial Attributed Network Anomaly Detection 2020 [10]
Unsupervised GNN OCGNN One-Class Graph Neural Networks for Anomaly Detection in Attributed Networks 2021 [11]
Unsupervised GNN GUIDE Higher-order Structure Based Anomaly Detection on Attributed Networks 2021 [12]

(ii) Utility functions :

Type Name Function Documentation
Metric eval_precision_at_k Calculating Precision@k eval_precision_at_k
Metric eval_recall_at_k Calculating Recall@k eval_recall_at_k
Metric eval_roc_auc Calculating ROC-AUC Score eval_roc_auc
Data gen_structure_outliers Generating structural outliers gen_structure_outliers
Data gen_attribute_outliers Generating attribute outliers gen_attribute_outliers

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.


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 [email protected].


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]Perini, L., Vercruyssen, V., Davis, J. Quantifying the confidence of anomaly detectors in their example-wise predictions. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases (ECML-PKDD), 2020.
[4]Sakurada, M. and Yairi, T., 2014, December. Anomaly detection using autoencoders with nonlinear dimensionality reduction. In Proceedings of the MLSDA 2014 2nd workshop on machine learning for sensory data analysis.
[5]Kipf, T.N. and Welling, M., 2016. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308.
[6]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).
[7]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).
[8](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).
[9]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).
[10]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).
[11]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.
[12]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).

pygod's People

Contributors

aha12345678 avatar canyuchen avatar kaize0409 avatar kayzliu avatar xiyanghu avatar xyvivian avatar yingtongdou avatar yzhao062 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.