π³ Credit Card Fraud & Anomaly Detection System
An interactive, production-ready Machine Learning Web Application built with Streamlit to detect fraudulent credit card transactions in real-time based on transformed PCA features and transaction metrics.
πΌοΈ Application Preview & UI
Interactive Streamlit dashboard designed with business-friendly feature inputs, fault-tolerant logic, and instant fraud probability metrics.
π Live Application
You can access and test the deployed application directly here: π Click Here to Launch Live Demo
πΌοΈ Key Features & Capabilities
- User-Friendly Interface: Business-oriented feature labels replacing raw mathematical PCA names ($V1$β$V5$) for seamless user experience.
- Smart Decision Dashboard: Clear status classification (Legitimate vs. Fraudulent), Risk Levels, and Model Confidence Score ($0-100%$) instead of raw binary values ($0/1$).
- Fault-Tolerant Pipeline: Robust exception handling ensuring that the UI renders smoothly even if dependencies or
.pklfiles are missing. - High Accuracy Benchmarks: Powered by high-precision ensemble tree classifiers trained on transaction risk patterns.
π Model Evaluation & Benchmarks
Multiple classification algorithms were evaluated to handle high variance and anomaly patterns. Here is the comparative accuracy metric across models:
| Model Name | Accuracy Score | Status |
|---|---|---|
| Random Forest Classifier π | 0.980 (98.0%) | Selected Model |
| Extra Trees Classifier π | 0.980 (98.0%) | Top Performer |
| K-Neighbors Classifier | 0.980 (98.0%) | Top Performer |
| XGBoost Classifier | 0.980 (98.0%) | Top Performer |
| AdaBoost Classifier | 0.975 (97.5%) | High Precision |
| Decision Tree Classifier | 0.970 (97.0%) | Baseline |
| Gradient Boosting Classifier | 0.970 (97.0%) | Baseline |
Selected Baseline: The Random Forest Classifier achieved 98.0% accuracy with reliable probability estimation for risk grading.
βοΈ Model Features & Input Parameters
| UI Parameter Name | Feature Code | Description / Domain Context |
|---|---|---|
| Transaction Timestamp | Time |
Elapsed time in seconds since the first dataset transaction |
| Transaction Behavior Factor 1 | V1 |
Primary PCA vector for transaction behavior patterns |
| Account Activity Vector 2 | V2 |
PCA vector capturing account usage variations |
| Security Risk Index 3 | V3 |
PCA vector measuring security variance |
| Anomalous Pattern Score 4 | V4 |
PCA vector identifying spending behavior anomalies |
| Location/Device Metric 5 | V5 |
PCA vector for contextual transaction parameters |
| Transaction Amount | Amount |
Total monetary value of the transaction ($) |
| Target Output | Class |
0 = Legitimate Transaction, 1 = Fraudulent |
π Repository Structure
βββ credit_card_fraud_synthetic.csv # Primary Transaction Dataset
βββ model.ipynb # Data Preprocessing, EDA & Model Training
βββ .gitignore # Git Ignore Rules
βββ .gitattributes # Git LFS Configuration
βββ app.py # Fault-Tolerant Streamlit Web Application
βββ model.pkl # Trained Machine Learning Model
βββ scaler.pkl # Fitted StandardScaler Object
βββ column.pkl # Feature Column Definitions
βββ requirements.txt # Python Dependencies
βββ README.md # Project Documentation
git clone https://github.com/amirsohail100/Credit-Card-Fraud-Detection-System.git
cd Credit-Card-Fraud-Detection-System
streamlit run app.py
pip install -r requirements.txt
π License
This project is licensed under the MIT License.
π Author
π€ Amir Sohail
A high-accuracy Machine Learning project evaluating multiple classifiers (Random Forest, Extra Trees, XGBoost, KNN at 98% accuracy) on Credit Card Fraud Data. Features dynamic inputs like Time, PCA components (V1-V5), and Amount to predict transaction legitimacy (Class) via a fault-tolerant Streamlit web UI.
Evaluation results
- Accuracy on Credit_Card_Fraud_Synthetic_Detectorself-reported0.980
