Skip to content

UB-GOLD/UB-GOLD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

420 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UB-GOLD

OverviewEnvironmentDatasetStartLicenseCitation

UB-GOLD

This is the official implementation of the following paper:

Unifying Unsupervised Graph-Level Out-of-Distribution Detection and Anomaly Detection: A Benchmark

UB-GOLD provides a fair and comprehensive platform to evaluate 18 existing unsupervised GLAD and GLOD works on 4 types of datasets and facilitates future GLAD/GLOD research.



Environment Setup

Before you begin, ensure that you have Anaconda or Miniconda installed on your system. This guide assumes that you have a CUDA-enabled GPU.

Required Dependencies :

  • torch>=2.0.1
  • torch_geometric>=2.4.0
  • python>=3.8
  • scikit-learn>=1.0.2
  • networkx>=2.6.3
  • rdkit>=2023.3.1
  • dgl>=2.1.0
  • pygcl>=0.1.2

You can easily create a virtual environment with all the required libraries for this project by running:
conda env create -n UBGOLD -f environment.yml

If errors occur during the above step, you may also install the dependencies using pip. Before using pip, it is strongly recommended to manually select the appropriate PyTorch version (compatible with your Python and CUDA versions). In this example, the Python version is 3.8.10 and the CUDA version is 11.8. Thus, the manually downloaded PyTorch and its extension packages are as follows:

  • torch-2.1.0+cu118-cp38-cp38-linux_x86_64.whl
  • torch_scatter-2.1.2+pt21cu118-cp38-cp38-linux_x86_64.whl
  • torch_sparse-0.6.18+pt21cu118-cp38-cp38-linux_x86_64.whl
  • torchvision-0.15.1+cu118-cp38-cp38-linux_x86_64.whl

If you use a different CUDA version, please refer to the PyTorch and Pyg websites for the appropriate versions.

For additional torch_geometric extensions, you can download them from this link.
For PyTorch packages, users in China can download them from the Nanjing University mirror site.

After manually configuring the PyTorch-related packages, run the following command to install the remaining Python libraries:
pip install -r requirements.txt

Codebase Folder

├── ...
├── benchmark (Benchmark execution)
│   ├── Source (Default hyperparameters)
│   ├── my_random_search.py
│   ├── mymain.py
│   ├── ...
├── results (Save the results)
├── data (Raw datasets)
├── GAOOD (Methods)
│   ├── nn
│   ├── detector
│   ├── ...
├── dataloader (Data preprocessing pipeline)
│   ├── ...
├── ...

Dataset Preparation

The data used in UB-GOLD should be downloaded in './data', and they can be downloaded from the following sources:

  1. Intrinsic Anomaly: TOX21
    • Tox21_p53, Tox21_HSE, Tox21_MMP,Tox21_PPAR-gamma
  2. Inter-Dataset Shift & Class-based Anomaly: TUDataset
    • COLLAB, IMDB-BINARY, REDDIT-BINARY, ENZYMES, PROTEINS
    • DD, BZR, AIDS, COX2, NCI1, DHFR
  3. Inter-Dataset Shift: OGB
    • BBBP, BACE, CLINTOX, LIPO, FREESOLV
    • TOXCAST, SOL, MUV, TOX21, SIDER
  4. Intra-Dataset Shift: DrugOOD
    • IC50 (SIZE, SCAFFOLD, ASSAY)
    • EC50 (SIZE, SCAFFOLD, ASSAY)
  5. Intra-Dataset Shift: GOOD

Quick Start

git clone https://github.com/UB-GOLD/UB-GOLD.git
cd ./UBGOLD

With Default Hyperparameters

The main experiments:

python benchmark/mymain.py 

OR

cp ./benchmark/Source/GOOD-D.sh .

bash GOOD-D.sh

The near-far OOD detection experiments:

python benchmark/near_far_ood.py 

OR

cp ./benchmark/Source/near_far_ood.sh .

bash near_far_ood.sh

The perturbation OOD detection experiments:

python benchmark/per_ood.py 

OR

cp ./benchmark/Source/per_ood.sh .

bash per_ood.sh

With Optimal Hyperparameters through Random Search

python benchmark/my_random_search.py

OR

cp ./benchmark/Source/search.sh .

bash search.sh

Supported Methods (16 Methods)

This part lists all the methods we include in this codebase. We support 16 popular methods for anomaly detection and OOD detection.

Table 1: 2-Step Methods

Category Models and References
Graph kernel with detector PK-SVM, PK-IF, WL-SVM, WL-IF
Self-supervised learning with detector IG-SVM, IG-IF, GCL-SVM, GCL-IF

Table 2: End-to-End Methods

Category Models and References
Graph neural network-based GLAD OCGIN, GLADC, GLocalKD, OCGTL, SIGNET, CVTGAD
Graph neural network-based GLOD GOOD-D , GraphDE

Citation

If you find our repository useful for your research, please consider citing our paper:

@article{wang2024unifying,
  title={Unifying Unsupervised Graph-Level Anomaly Detection and Out-of-Distribution Detection: A Benchmark},
  author={Wang, Yili and Liu, Yixin and Shen, Xu and Li, Chenyu and Ding, Kaize and Miao, Rui and Wang, Ying and Pan, Shirui and Wang, Xin},
  journal={arXiv preprint arXiv:2406.15523},
  year={2024}
}

Reference

UB-GOLD has completed the approaches related to unsupervised Graph detection for Tables 1 and 2. As for some special scenarios in Tables 3-5, we will gradually adapt them to this benchmark.

Table 1: Unsupervised GLAD

ID Paper Category Conference
1 On using classification datasets to evaluate graph outlier detection: Peculiar observations and new insights GLAD Big Data 2023
2 Deep graph-level anomaly detection by glocal knowledge distillation GLAD WSDM 2022
3 Raising the bar in graph-level anomaly detection GLAD IJCAI 2022
4 Towards self-interpretable graph-level anomaly detection GLAD NeurIPS 2023
5 Deep graph level anomaly detection with contrastive learning GLAD Nature scientific reports 2022
6 CVTGAD: Simplified Transformer with Cross-View Attention for Unsupervised Graph-Level Anomaly Detection GLAD ECML-PKDD 2023

Table 2: Unsupervised GLOD

ID Paper Category Conference
7 Good-d: On unsupervised graph out-of-distribution detection GLOD WSDM 2023
8 Graphde: A generative framework for debiased learning and out-of-distribution detection on graphs GLOD NeurIPS 2022
9 A Data-centric Framework to Endow Graph Neural Networks with Out-Of-Distribution Detection Ability GLOD KDD 2023
10 GOODAT: Towards Test-time Graph Out-of-Distribution Detection GLOD AAAI 2024

Table 3: Other Approaches (Supervised Setting)

ID Paper Category Conference
1 Dual-discriminative graph neural network for imbalanced graph-level anomaly detection GLAD NeurIPS 2022
2 Towards graph-level anomaly detection via deep evolutionary mapping GLAD KDD 2023
3 Rayleigh Quotient Graph Neural Networks for Graph-level Anomaly Detection GLAD ICLR 2024
4 SGOOD: Substructure-enhanced Graph-Level Out-of-Distribution Detection GLOD Arxiv 2023

Table 4: Other Approaches (Scenario Limitations (limited to molecular graphs))

ID Paper Category Conference
5 Optimizing OOD Detection in Molecular Graphs: A Novel Approach with Diffusion Models GLOD KDD 2024

About

ICLR25_Unifying Unsupervised Graph-Level Out-of-Distribution Detection and Anomaly Detection: A Benchmark

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors