Skip to content

dagiteferi/fraud-detection-models

Repository files navigation

🚀 Fraud Detection System

A machine learning-powered fraud detection system for e-commerce and banking transactions. This project includes data preprocessing, feature engineering, model training, explainability (SHAP & LIME), API development with Flask, deployment with Docker, and visualization with Dash.

📌 Project Overview

Fraud detection is critical for securing online transactions and banking operations. This system detects fraudulent activities in e-commerce and bank credit transactions using advanced machine learning techniques and real-time monitoring.

📑 Table of Contents

🔹 Key Features

✔️ Data preprocessing and feature engineering
✔️ Fraud detection model training with multiple algorithms
✔️ Model explainability using SHAP and LIME
✔️ REST API for real-time fraud detection (Flask)
✔️ Deployment using Docker
✔️ Interactive fraud analysis dashboard (Dash)

📂 Project Structure

  📂 dagiteferi-fraud-detection-models/
├── 📜 README.md
├── 📜 requirements.txt
├── 🏠 fraud_detection_app/
│   ├── 📦 Dockerfile
│   ├── 🔄 callbacks.py
│   ├── 📜 requirements.txt
│   ├── 🚀 serve_model.py
│   ├── 📝 .http
│   ├── 📂 assets/
│   │   ├── 🎨 styles.css
│   │   ├── 📜 scripts.js
├── 📂 logs/
├── 📖 notebooks/
│   ├── 📜 README.md
│   ├── 📊 Data Analysis Preprocessing.ipynb
│   ├── 🧐 Model_Explainability.ipynb
│   ├── 🤖 model_Training_credit_card.ipynb
│   ├── 🔍 model_Training_fraud_data.ipynb
│   ├── 📜 __init__.py
├── 📝 scripts/
│   ├── 📜 README.md
│   ├── ⚙️ FeatureEngineering.py
│   ├── 🧐 Model_Explainability.py
│   ├── 📊 bivariate.py
│   ├── 📝 logger.py
│   ├── 🤖 model.py
│   ├── 📈 univariate.py
│   ├── 📜 __init__.py
├── 🔧 src/
│   ├── 📜 __init__.py
│   ├── 📂 data_loading.py
│   ├── 📂 file_structure.py
├── 🧪 tests/
│   ├── 📜 __init__.py
├── 🏗️ .github/
│   ├── 📂 workflows/
│   │   ├── 🔄 unittests.yml

🛠 Tech Stack

  • Programming Language: Python (Pandas, NumPy, Scikit-learn, TensorFlow/PyTorch)
  • Machine Learning Models: Logistic Regression, Random Forest, Gradient Boosting, LSTM, CNN
  • API & Deployment: Flask, Docker
  • Explainability: LIME
  • Visualization: Dash, Matplotlib, Seaborn

🔧 Installation

1️⃣ Clone the repository

git clone https://github.com/dagiteferi/fraud-detection-models.git
cd fraud-detection-models

2️⃣ Create a virtual environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3️⃣ Install dependencies

pip install -r requirements.txt

4️⃣ Run the API

cd fraud_detection_app
python serve_model.py

The API will run at http://127.0.0.1:5000/.

5️⃣ Run the Dashboard

cd fraud_detection_app
python serve_model.py

The Dashboard will run at http://127.0.0.1:5000/.

🚀 Running with Docker

1️⃣ Build the Docker Image

docker build -t fraud-detection-model -f fraud_detection_app/Dockerfile .

2️⃣ Run the Docker Container

docker run -d -p 5000:5000 --name fraud-detection-container fraud-detection-model

The API will be accessible at http://127.0.0.1:5000/ inside the container.

📊 Dashboard Features

Dashboard Features

  1. Fraud Detection Summary:

    • Total Transactions: Displays the total number of transactions in the dataset.
    • Fraud Cases: Shows the total number of fraudulent transactions.
    • Fraud Percentage: Displays the percentage of fraudulent transactions out of the total.
  2. Fraud Trends Over Time:

    • A time series graph visualizing the number of fraud cases over time. It helps track how fraud patterns evolve.
  3. Geographic Fraud Analysis:

    • A bar chart representing the fraud cases grouped by geographic locations (IP addresses). This helps identify regions with high fraudulent activity.
  4. Device-based Fraud Analysis:

    • A bar chart showing fraud cases broken down by device ID, allowing identification of devices commonly used for fraudulent transactions.
  5. Browser-based Fraud Analysis:

    • A bar chart comparing fraud cases across different browsers, helping to identify any browser-specific fraud patterns.

About

This project aims to develop the detection of fraudulent transactions in e-commerce using advanced machine learning techniques.It involves data analysis, preprocessing, feature engineering, model building, and deployment.The project includes API with Flask, containerization with Docker, and dashboards with Dash .

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors