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.
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.
- Project Overview
- Key Features
- Project Structure
- Tech Stack
- Installation
- Running with Docker
- Dashboard 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)
📂 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
- 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
git clone https://github.com/dagiteferi/fraud-detection-models.git
cd fraud-detection-models2️⃣ Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcd fraud_detection_app
python serve_model.pyThe API will run at http://127.0.0.1:5000/.
cd fraud_detection_app
python serve_model.pyThe Dashboard will run at http://127.0.0.1:5000/.
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-modelThe API will be accessible at http://127.0.0.1:5000/ inside the container.
-
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.
-
Fraud Trends Over Time:
- A time series graph visualizing the number of fraud cases over time. It helps track how fraud patterns evolve.
-
Geographic Fraud Analysis:
- A bar chart representing the fraud cases grouped by geographic locations (IP addresses). This helps identify regions with high fraudulent activity.
-
Device-based Fraud Analysis:
- A bar chart showing fraud cases broken down by device ID, allowing identification of devices commonly used for fraudulent transactions.
-
Browser-based Fraud Analysis:
- A bar chart comparing fraud cases across different browsers, helping to identify any browser-specific fraud patterns.