Skip to content

RISHABH4SAHNI/Payment-Fraud-Detection-using-Graph-Neural-Networks-

Repository files navigation

Payment Fraud Detection using Graph Neural Networks

Python PyTorch License

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.

Project Overview

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

Project Structure

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

Getting Started

Prerequisites

  • Python 3.8 or higher
  • CUDA-capable GPU (optional but recommended)
  • Git

Installation

  1. 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
  2. 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
  3. Download the dataset

    # The script will automatically download the PaySim dataset from Kaggle
    python src/data/download_data.py

Quick Start

  1. Data Preprocessing

    python src/data/preprocessing.py
  2. Train the GCN Model

    python src/training/train_gcn.py
  3. Run Hyperparameter Optimization

    python src/training/hyperparameter_tuning.py

About

Built a machine learning model to detect financial fraud using a synthetic dataset. Focused on feature engineering, dimensionality reduction, and model evaluation. The result is a high-accuracy, reproducible pipeline for real-time fraud detection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors