A comprehensive implementation of fraud detection in payment systems using Graph Neural Networks (GNNs). This project leverages the power of graph-based machine learning to identify fraudulent transactions by modeling the relationships between payment entities.
Financial fraud detection is a critical challenge in the digital payment ecosystem. Traditional machine learning approaches often fall short in capturing the complex relationships between transactions, users, and merchants. This project implements a Graph Neural Network approach that:
- Models payment transactions as a graph structure
- Captures complex relationships between entities
- Achieves high accuracy in fraud detection
- Provides interpretable results through graph analysis
Payment-Fraud-Detection-using-Graph-Neural-Networks/
├── data/ # Data directory
│ ├── raw/ # Raw dataset files
│ ├── processed/ # Processed data files
│ └── README.md # Data description
├── src/ # Source code
│ ├── models/ # Model implementations
│ │ ├── gcn_classifier.py # GCN model class
│ │ └── baseline_models.py # Traditional ML models
│ ├── data/ # Data processing modules
│ │ ├── preprocessing.py # Data preprocessing
│ │ └── graph_construction.py # Graph construction utilities
│ ├── training/ # Training scripts
│ │ ├── train_gcn.py # GCN training script
│ │ └── hyperparameter_tuning.py # Optuna optimization
│ └── evaluation/ # Evaluation utilities
│ └── metrics.py # Evaluation metrics
├── notebooks/ # Jupyter notebooks
│ ├── 01_data_exploration.ipynb # Data analysis
│ ├── 02_graph_construction.ipynb # Graph building
│ └── 03_model_comparison.ipynb # Model comparison
├── results/ # Results and outputs
│ ├── models/ # Saved models
│ ├── figures/ # Plots and visualizations
│ └── reports/ # Analysis reports
├── tests/ # Unit tests
├── requirements.txt # Python dependencies
├── environment.yml # Conda environment file
├── setup.py # Package setup
└── README.md # This file
- Python 3.8 or higher
- CUDA-capable GPU (optional but recommended)
- Git
-
Clone the repository
git clone https://github.com/your-username/Payment-Fraud-Detection-using-Graph-Neural-Networks.git cd Payment-Fraud-Detection-using-Graph-Neural-Networks -
Create a virtual environment
# Using conda (recommended) conda env create -f environment.yml conda activate fraud-detection-gnn # Or using pip python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Download the dataset
# The script will automatically download the PaySim dataset from Kaggle python src/data/download_data.py
-
Data Preprocessing
python src/data/preprocessing.py
-
Train the GCN Model
python src/training/train_gcn.py
-
Run Hyperparameter Optimization
python src/training/hyperparameter_tuning.py