Awesome
<p align="center"> <br> <a href="https://image.flaticon.com/icons/svg/1671/1671517.svg"> <img src="https://github.com/safe-graph/DGFraud/blob/master/DGFraud_logo.png" width="400"/> </a> <br> <p> <p align="center"> <a href="https://travis-ci.org/github/safe-graph/DGFraud"> <img alt="PRs Welcome" src="https://travis-ci.org/safe-graph/DGFraud.svg?branch=master"> </a> <a href="https://github.com/safe-graph/DGFraud/blob/master/LICENSE"> <img alt="GitHub" src="https://img.shields.io/github/license/safe-graph/DGFraud"> </a> <a href="https://github.com/safe-graph/DGFraud/pulls"> <img alt="GitHub release" src="https://img.shields.io/github/v/release/safe-graph/DGFraud?include_prereleases"> </a> <a href="https://github.com/safe-graph/DGFraud/archive/master.zip"> <img alt="PRs" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg"> </a> </p> <h3 align="center"> <p>A Deep Graph-based Toolbox for Fraud Detection </h3>Introduction
May 2021 Update: The DGFraud has upgraded to TensorFlow 2.0! Please check out DGFraud-TF2
DGFraud is a Graph Neural Network (GNN) based toolbox for fraud detection. It integrates the implementation & comparison of state-of-the-art GNN-based fraud detection models. The introduction of implemented models can be found here. <!-- (Add introduction blogs links). -->
We welcome contributions on adding new fraud detectors and extending the features of the toolbox. Some of the planned features are listed in TODO list.
If you use the toolbox in your project, please cite one of the two papers below and the algorithms you used :
CIKM'20 (PDF)
@inproceedings{dou2020enhancing,
title={Enhancing Graph Neural Network-based Fraud Detectors against Camouflaged Fraudsters},
author={Dou, Yingtong and Liu, Zhiwei and Sun, Li and Deng, Yutong and Peng, Hao and Yu, Philip S},
booktitle={Proceedings of the 29th ACM International Conference on Information and Knowledge Management (CIKM'20)},
year={2020}
}
SIGIR'20 (PDF)
@inproceedings{liu2020alleviating,
title={Alleviating the Inconsistency Problem of Applying Graph Neural Network to Fraud Detection},
author={Liu, Zhiwei and Dou, Yingtong and Yu, Philip S. and Deng, Yutong and Peng, Hao},
booktitle={Proceedings of the 43nd International ACM SIGIR Conference on Research and Development in Information Retrieval},
year={2020}
}
Useful Resources
- PyGOD: A Python Library for Graph Outlier Detection (Anomaly Detection)
- UGFraud: An Unsupervised Graph-based Toolbox for Fraud Detection
- Graph-based Fraud Detection Paper List
- Awesome Fraud Detection Papers
- Attack and Defense Papers on Graph Data
- PyOD: A Python Toolbox for Scalable Outlier Detection (Anomaly Detection)
- PyODD: An End-to-end Outlier Detection System
- DGL: Deep Graph Library
- Outlier Detection DataSets (ODDS)
Table of Contents
Installation
git clone https://github.com/safe-graph/DGFraud.git
cd DGFraud
python setup.py install
Requirements
* python 3.6, 3.7
* tensorflow>=1.14.0,<2.0
* numpy>=1.16.4
* scipy>=1.2.0
* networkx<=1.11
Datasets
DBLP
We uses the pre-processed DBLP dataset from Jhy1993/HAN You can run the FdGars, Player2Vec, GeniePath and GEM based on the DBLP dataset. Unzip the archive before using the dataset:
cd dataset
unzip DBLP4057_GAT_with_idx_tra200_val_800.zip
Example dataset
We implement example graphs for SemiGNN, GAS and GEM in data_loader.py
. Because those models require unique graph structures or node types, which cannot be found in opensource datasets.
Yelp dataset
For GraphConsis, we preprocessed Yelp Spam Review Dataset with reviews as nodes and three relations as edges.
The dataset with .mat
format is located at /dataset/YelpChi.zip
. The .mat
file includes:
net_rur, net_rtr, net_rsr
: three sparse matrices representing three homo-graphs defined in GraphConsis paper;features
: a sparse matrix of 32-dimension handcrafted features;label
: a numpy array with the ground truth of nodes.1
represents spam and0
represents benign.
The YelpChi data preprocessing details can be found in our CIKM'20 paper. To get the complete metadata of the Yelp dataset, please email to ytongdou@gmail.com for inquiry.
User Guide
Running the example code
You can find the implemented models in algorithms
directory. For example, you can run Player2Vec using:
python Player2Vec_main.py
You can specify parameters for models when running the code.
Running on your datasets
Have a look at the load_data_dblp() function in utils/utils.py for an example.
In order to use your own data, you have to provide:
- adjacency matrices or adjlists (for GAS);
- a feature matrix
- a label matrix then split feature matrix and label matrix into testing data and training data.
You can specify a dataset as follows:
python xx_main.py --dataset your_dataset
or by editing xx_main.py
The structure of code
The repository is organized as follows:
algorithms/
contains the implemented models and the corresponding example code;base_models/
contains the basic models (GCN);dataset/
contains the necessary dataset files;utils/
contains:- loading and splitting the data (
data_loader.py
); - contains various utilities (
utils.py
).
- loading and splitting the data (
Implemented Models
Model Comparison
Model | Application | Graph Type | Base Model |
---|---|---|---|
SemiGNN | Financial Fraud | Heterogeneous | GAT, LINE, DeepWalk |
Player2Vec | Cyber Criminal | Heterogeneous | GAT, GCN |
GAS | Opinion Fraud | Heterogeneous | GCN, GAT |
FdGars | Opinion Fraud | Homogeneous | GCN |
GeniePath | Financial Fraud | Homogeneous | GAT |
GEM | Financial Fraud | Heterogeneous | GCN |
GraphSAGE | Opinion Fraud | Homogeneous | GraphSAGE |
GraphConsis | Opinion Fraud | Heterogeneous | GraphSAGE |
HACUD | Financial Fraud | Heterogeneous | GAT |
TODO List
- Implementing mini-batch training
- The log loss for GEM model
- Time-based sampling for GEM
- Add sampling methods
- Benchmarking SOTA models
- Scalable implementation
- Pytorch implementation
How to Contribute
You are welcomed to contribute to this open-source toolbox. The detailed instructions will be released soon. Currently, you can create issues or email to bdscsafegraph@gmail.com for inquiry.