Sign inSign up

bytebard101/fraudguard

By bytebard101

β€’Updated 8 months ago

An ML-based web application that predicts whether transactions are fraudulent or safe.

Image
Languages & frameworks
Machine learning & AI
Data science
0

544

bytebard101/fraudguard repository overview

β πŸ›‘οΈ FraudGuard Batch Analyzer

Check the GitHub repository of this project here⁠

A machine learning–powered web application that detects fraudulent credit card transactions in bulk using a robust XGBoost model. Built with Flask, Scikit-Learn, and Pandas, this project provides a sophisticated and automated solution for financial risk analysis. This project demonstrates the power of self-healing systems and advanced machine learning in cybersecurity applications.


β πŸš€ Overview

FraudGuard Batch Analyzer enables users to upload CSV files containing anonymized transaction data. It uses a trained XGBoost Classifier optimized via tailored research to predict if a transaction is Fraudulent or Valid. The system includes:

  • Interactive Dashboard: Visualizes risk statistics and high-risk transactions.
  • Batch Processing: Handles large datasets instantly.
  • Self-Healing: Automatically regenerates model artifacts if they are missing.

β πŸ“Έ Screenshots

(Screenshots coming soon)


β πŸ“Š Dataset

The dataset is artificially balanced. That is why, the number of 0 and 1 classes are equal.

  • Features:
    • V1-V28: Anonymized features.
    • Amount: Transaction amount.

β βš™οΈ Model Architecture

StepDescription
ImputationMissing values handled using median strategy
ScalingStandardized with StandardScaler
Dimensionality ReductionPCA (n_components=24)
ClassifierXGBClassifier (n_estimators=600, max_depth=10, learning_rate=0.1)

Final model artifacts are serialized with joblib as:

models/
β”œβ”€β”€ pipe.pkl
β”œβ”€β”€ feat_names.pkl

⁠πŸ§ͺ Model Selection Research

We rigorously tested multiple algorithms including Random Forest, SVC, and XGBoost to find the optimal architecture. Using RandomizedSearchCV, we identified that XGBoost with PCA feature extraction yielded the best balance of speed and accuracy.

Here is the Classification Report for the final model:

precisionrecallf1-scoresupport
01.001.001.005000
11.001.001.005000
accuracy1.001.001.001.00
macro avg1.001.001.0010000
weighted avg1.001.001.0010000

You can find the detailed research code in the research.py⁠ file included in the repo. However, for the best viewing experience, use the HTML copy of the notebook which is available in the research.html⁠ file.

⁠Performance Note

The model achieves near-perfect performance on the provided dataset. This behavior was investigated using a label-shuffling diagnostic test, which reduced performance to random chance (~50%), confirming the absence of data leakage.

The dataset is already anonymized, balanced, and pre-processed (PCA-transformed), which significantly simplifies the classification task. As such, these results should be viewed as a demonstration of modeling correctness rather than real-world deployability.


⁠🧩 Project Structure

FRAUD DETECTION/
β”œβ”€β”€ Dataset/
β”‚   └── creditcard_2023.csv  # Primary dataset
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ feat_names.pkl       # Serialized feature names
β”‚   └── pipe.pkl             # Serialized machine learning pipeline
β”œβ”€β”€ processed/               # Directory for analyzed output files (Ignored)
β”œβ”€β”€ static/                  # Static assets for the web application
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ index.html           # Upload page
β”‚   └── dashboard.html       # Results dashboard
β”œβ”€β”€ uploads/                 # Temporary storage for user uploads (Ignored)
|
β”œβ”€β”€ .gitignore               # Files to exclude from version control
β”œβ”€β”€ app.py                   # Main Flask application file
β”œβ”€β”€ fit.py                   # Script for training and saving the model
β”œβ”€β”€ LICENSE                  # Licensing information
β”œβ”€β”€ research.py              # Marimo notebook for model research
└── requirements.txt         # Python package dependencies

β πŸ’» Installation & Usage

⁠1️⃣ Clone the Repository
git clone https://github.com/ByteBard58/Fruad-Detection
cd "Fruad Detection"
⁠2️⃣ Install Dependencies
pip install -r requirements.txt
⁠3️⃣ Configure Environment

Create a .env file in the root directory:

DATA_PATH="Dataset/creditcard_2023.csv"
⁠4️⃣ Run the App
python app.py
⁠5️⃣ Run Marimo Notebooks (Optional)

To explore the research process interactively:

marimo edit research.py

This command will open the notebook in your default browser.


⁠🐳 Run the app directly via Dockerhub Image

Coming Soon


⁠🌠 Web Interface

Users upload a CSV file containing transaction data. The system:

  • Validates the columns.
  • Processes the file using the pre-trained pipeline.
  • Generates a Risk Dashboard with key insights.
  • Allows downloading of the processed file with risk probability scores appended.

Note: The sophisticated UI/UX design was implemented with assistance from modern AI coding tools to ensure a premium user experience.


⁠🧰 Tech Stack

  • Languages: Python, HTML, CSS, JavaScript
  • Libraries: Flask, Scikit-Learn, Pandas, NumPy, XGBoost, Joblib, Marimo
  • Dataset Source: Kaggle Credit Card Fraud Detection

⁠πŸͺ Author

Sakib ( ByteBard58 )

Student | Aspiring Computer Engineer | AI & ML Enthusiast

πŸ“ GitHub Profile: ByteBard58⁠


β πŸ˜ƒ Appreciation

I appreciate you taking the time to look over my work. I hope you found it interesting and enjoyable. If you could star it on GitHub, it would be really appreciated. 🌟

Do not hesitate to contact us if you have any queries, recommendations, or topics you would want to talk about. My [GitHub profile page] (http://www.github.com/ByteBard58⁠) has my contact details.

Have a great day !

Tag summary

Content type

Image

Digest

sha256:282f53d05…

Size

1 GB

Last updated

8 months ago

docker pull bytebard101/fraudguard