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 [DLS+20] and security systems [CCL+21].

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 anomalies 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.

Implemented Algorithms#

PyGOD toolkit consists of two major functional groups:

(i) Node-level detection :

Type

Backbone

Abbr

Algorithm

Year

Class

Unsupervised

GNN

DOMINANT

Deep anomaly detection on attributed networks

2019

pygod.models.dominant.DOMINANT

Unsupervised

GNN

AnomalyDAE

AnomalyDAE: Dual autoencoder for anomaly detection on attributed networks

2020

pygod.models.anomalydae.AnomalyDAE

Unsupervised

GNN

DONE

Outlier Resistant Unsupervised Deep Architectures for Attributed Network Embedding

2020

pygod.models.done.DONE

Unsupervised

GNN

AdONE

Outlier Resistant Unsupervised Deep Architectures for Attributed Network Embedding

2020

pygod.models.adone.AdONE

Unsupervised

GNN

GCNAE

Variational Graph Auto-Encoders

2021

pygod.models.gcnae.GCNAE

Unsupervised

NN

MLPAE

Neural Networks and Deep Learning

2021

pygod.models.mlpae.MLPAE

Unsupervised

GNN

GUIDE

Higher-order Structure Based Anomaly Detection on Attributed Networks

2021

pygod.models.guide.GUIDE

Unsupervised

GNN

OCGNN

One-Class Graph Neural Networks for Anomaly Detection in Attributed Networks

2021

pygod.models.ocgnn.OCGNN

Unsupervised

MF

ONE

Outlier aware network embedding for attributed networks

2019

pygod.models.one.ONE

Unsupervised

GAN

GAAN

Generative Adversarial Attributed Network Anomaly Detection

2020

pygod.models.gaan.GAAN

(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


API CheatSheet#

The following APIs are applicable for all detector models for easy use.

Key Attributes of a fitted model:

Input of PyGOD: Please pass in a PyTorch Geometric (PyG) data object. See PyG data processing examples.