dark-ui/automl-fraud-detection
๐ก๏ธ AutoML-X โ Intelligent Fraud Detection System

๐ Overview
AutoML-X is a production-ready, end-to-end machine learning system for credit card fraud detection. It automatically trains, evaluates, and selects the best model from 5 competing algorithms using cross-validation, applies feature engineering on raw transaction data, optimizes the decision threshold based on real business costs, and serves predictions through a FastAPI REST API with full SHAP explainability.
Built as a Minor Project at Madhav Institute of Technology and Science.
๐ฏ Key Results
๐ Live Demo
๐ Evaluation Reports
ROC Curve (AUC = 0.97482)
Confusion Matrix (Threshold = 0.20603)
๐ SHAP Explainability
Feature Importance โ Mean |SHAP| (Top 20 Features)
Feature Impact Direction โ Beeswarm Plot
Top fraud indicators:V14,V4,V12,V10,V3โ consistent with published research on this dataset.
๐๏ธ System Architecture
creditcard.csv
โ
โผ
DataLoader โโโบ imbalance detection (0.17% fraud rate)
โ
โผ
DataCleaner โโโบ remove duplicates, impute missing, log outliers
โ
โผ
Feature Engineering (+5 derived features)
โโโ Hour (fraud varies by time of day)
โโโ Night_txn (10pmโ6am binary flag)
โโโ Amount_log (log transform โ compresses skew)
โโโ Amount_zscore (how unusual is this amount)
โโโ High_amount (Amount > $1,000 binary flag)
โ
โผ
SMOTE Oversampling โโโบ balanced training set (50/50)
โ
โผ
AutoModelSelector โ 5 models compete via cross-validation
โโโ LogisticRegression (ROC-AUC: 0.99812)
โโโ RandomForest (ROC-AUC: 0.99999) โ
selected
โโโ LightGBM_Balanced (ROC-AUC: 0.99998)
โโโ LightGBM_HighRecall (ROC-AUC: 0.99997)
โโโ XGBoost_HighRecall (ROC-AUC: 0.99993)
โ
โผ
BusinessCostOptimizer โโโบ threshold = 0.20603
โ cost = $113,800
โผ
best_model.pkl โโโบ FastAPI โโโบ /predict
โ โโโโบ /predict/batch
โ โโโโบ SHAP explanation per transaction
โผ
DriftDetector โโโบ PSI + KS test on new data
โ
โผ
ModelMonitor โโโบ SQLite logging + alert rules
โ
โผ
AlertManager โโโบ Slack webhook + log file
โ
โผ
MLflow โโโบ experiment tracking + model registry๐ง New: Monitoring & Alerting
Alert rules:
- ๐ด CRITICAL โ Fraud rate exceeds 30% in last 100 predictions
- ๐ก WARNING โ Average model confidence drops below 60%
- ๐ก WARNING โ Data drift detected (PSI โฅ 0.1 on 10%+ of features)
๐งช Experimentation Journey
๐ฐ Business Cost Optimization
Total Cost = (Missed Frauds ร $10,000) + (False Alarms ร $200)
Final result at threshold 0.20603:
10 frauds missed ร $10,000 = $100,000
69 false alarms ร $200 = $13,800
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Total minimum cost = $113,800๐ Quick Start
# 1. Clone
git clone https://github.com/Sujal-baghela/Automl-fraud-detection.git
cd Automl-fraud-detection
# 2. Install
pip install -r requirements.txt
# 3. Add dataset
# Download creditcard.csv from Kaggle โ place at Data/creditcard.csv
# 4. Train
python -m Scripts.train
# 5. Run API
uvicorn app.api:app --reload --port 8000
# 6. Run Dashboard
streamlit run app/dashboard.py
# 7. Run MLflow
mlflow ui --port 5000
# 8. Docker (all services)
docker-compose up --build๐ API Endpoints
๐ Project Structure
automl-x/
โโโ .github/workflows/ci.yml
โโโ app/
โ โโโ api.py # FastAPI + monitoring integration
โ โโโ dashboard.py # Streamlit dashboard
โ โโโ universal.py
โโโ src/
โ โโโ monitor.py # ModelMonitor โ SQLite logging
โ โโโ alerting.py # AlertManager โ Slack + log file
โ โโโ drift_detector.py
โ โโโ fraud_system.py
โ โโโ inference_engine.py
โ โโโ model_selector.py
โ โโโ ...
โโโ tests/
โ โโโ test_monitor.py # 96 tests
โ โโโ test_pipeline.py
โ โโโ ...
โโโ models/
โ โโโ best_model.pkl
โ โโโ drift_reference.json
โโโ Dockerfile
โโโ supervisord.conf
โโโ docker-compose.yml
โโโ requirements.txt๐ฆ Tech Stack
๐ฅ Authors
Sujal Baghela โ @Sujal-baghela
Sameer Bhilware โ @SameerBhilware-ui
Institution: Madhav Institute of Technology and Science
๐ License
MIT License
