Home

Awesome

<p align="center"> <a href="https://zhoushengisnoob.github.io/projects/DGLD_Fronted/index.html"> <img src="images/DGLD_logo.jpg" width="200" alt="DGLD LOGO"/></a> <p> <h1 align="center">A Deep Graph Anomaly Detection Library <br> based on DGL</h1> <p align="center"> <b> <a href="https://zhoushengisnoob.github.io/projects/DGLD_Fronted/index.html">Website</a> | <a href="https://zhoushengisnoob.github.io/DGLD/doc/docstring_html/html/dgld.html">Doc</a> </b> </p>

DGLD is an open-source library for Deep Graph Anomaly Detection based on pytorch and DGL. It provides unified interface of popular graph anomaly detection methods, including the data loader, data augmentation, model training and evaluation. Also, the widely used modules are well organized so that developers and researchers can quickly implement their own designed models.

News

Installation

Basic environment installation:

conda create -n dgld python=3.8.0
conda activate dgld
conda install cudatoolkit==11.3.1
pip install dgl-cu113==0.8.1 dglgo==0.0.1 -f https://data.dgl.ai/wheels/repo.html
pip install torch==1.11.0+cu113  -f https://download.pytorch.org/whl/torch_stable.html

Install from source code

Then clone the DGLD project, enter the directory and run:

git clone git@github.com:EagleLab-ZJU/DGLD.git
pip install -r requirements.txt

To check whether you have successfully installed the package and environment, you can simply run

python example.py

Install from pypi

pip install DGLD

Now you can enjoy DGLD!

Quick Start

We support an example.py showing how it works. Here, we introduce how to simply run DGLD, following 4 steps.

Dataloader

DGLD support multiple data import methods, including PyTorch Geometric, DGL and custom data. DGLD combines the process of data load and anomaly injection. Except for some basic datasets(including "Cora", "Citeseer", "Pubmed", "BlogCatalog", "Flickr", "ogbn-arxiv" and "ACM"), DGLD also accept custom data.

Anomaly Injection

In anomaly detection, DGLD inject the abnormal node in two methods, structural and contextual, by two parameters - p and k. gnd_dataset is an instance of GraphNodeAnomalyDectionDataset. g is an instance of DGL.Graph. label is an instnace of torch.Tensor, presenting the anomaly class. Following is an example showing that a few lines of codes are sufficient to load and inject.

from DGLD.utils.dataset import GraphNodeAnomalyDectionDataset

gnd_dataset = GraphNodeAnomalyDectionDataset("Cora", p = 15, k = 50)
g = gnd_dataset[0]
label = gnd_dataset.anomaly_label

Model

DGLD supports some basic methods. It's easy to construct and train model.

from DGLD.models import CoLA

model = CoLA(in_feats = g.ndata['feat'].shape[1])

Train and Evaluation

Function fit need parameters to specify number of epoch and device. For gpu, device should be a int, while a string 'cpu' for cpu.

from DGLD.utils.evaluation import split_auc

model.fit(g, num_epoch=5, device=0)
result = model.predict(g, auc_test_rounds=2)
print(split_auc(label, result))

Native Datasets

The DGLD provides native graph anomaly detection datasets that widely used by existing methods.

Datasetnodesedgesattributesanomalies
BlogCatalog51961717438189300
Flickr757523973812047450
ACM16484719808337600
Cora270854291433150
Citeseer332747323703150
Pubmed1971744338500600
ogbn-arxiv16934311662431286000

Implemented Results (Sorted Results)

MethodCoraCiteseerPubmedBlogCatalogFlickrACMArxiv
CoLA0.88230.87650.96320.64880.57900.81940.8833
SL-GAD0.89370.90030.95320.77820.76640.81460.7483
ANEMONE0.89160.86330.9630----
DOMINANT0.85550.82360.82950.77950.75590.7067-
ComGA0.96770.80200.92050.79080.73460.7147-
AnomalyDAE0.96790.88320.91820.76660.74370.7091-
ALARM0.94790.83180.82960.77180.75960.6952-
AAGNN0.73710.76160.74420.76480.73880.4868-
GUIDE0.97850.97780.95350.76750.73370.7153-
CONAD0.96460.91160.93960.78630.73950.70050.6365
GAAN0.79640.79790.78620.73200.7510-0.8605
DONE0.96360.89480.88030.78420.75550.70940.7093
ONE0.97170.99000.89910.79240.77120.7072-
AdONE0.96290.89350.90300.74380.7595-0.7651
GCNAE0.77070.76960.79410.73630.7529-0.7530
MLPAE0.76170.75380.72110.73990.7514-0.7382
SCAN0.65080.66710.73610.49260.6498-0.6905

Upcoming Features