An ML-based web application that predicts whether transactions are fraudulent or safe.
544
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.
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:
(Screenshots coming soon)
0 β Valid Transaction1 β Fraudulent TransactionThe dataset is artificially balanced. That is why, the number of 0 and 1 classes are equal.
V1-V28: Anonymized features.Amount: Transaction amount.| Step | Description |
|---|---|
| Imputation | Missing values handled using median strategy |
| Scaling | Standardized with StandardScaler |
| Dimensionality Reduction | PCA (n_components=24) |
| Classifier | XGBClassifier (n_estimators=600, max_depth=10, learning_rate=0.1) |
Final model artifacts are serialized with joblib as:
models/
βββ pipe.pkl
βββ feat_names.pkl
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:
| precision | recall | f1-score | support | |
|---|---|---|---|---|
| 0 | 1.00 | 1.00 | 1.00 | 5000 |
| 1 | 1.00 | 1.00 | 1.00 | 5000 |
| accuracy | 1.00 | 1.00 | 1.00 | 1.00 |
| macro avg | 1.00 | 1.00 | 1.00 | 10000 |
| weighted avg | 1.00 | 1.00 | 1.00 | 10000 |
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.
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.
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
git clone https://github.com/ByteBard58/Fruad-Detection
cd "Fruad Detection"
pip install -r requirements.txt
Create a .env file in the root directory:
DATA_PATH="Dataset/creditcard_2023.csv"
python app.py
To explore the research process interactively:
marimo edit research.py
This command will open the notebook in your default browser.
Coming Soon
Users upload a CSV file containing transaction data. The system:
Note: The sophisticated UI/UX design was implemented with assistance from modern AI coding tools to ensure a premium user experience.
Sakib ( ByteBard58 )
Student | Aspiring Computer Engineer | AI & ML Enthusiast
π GitHub Profile: ByteBard58β
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 !
Content type
Image
Digest
sha256:282f53d05β¦
Size
1 GB
Last updated
8 months ago
docker pull bytebard101/fraudguard