Update README.md
Browse files
README.md
CHANGED
|
@@ -10,55 +10,98 @@ tags:
|
|
| 10 |
pinned: false
|
| 11 |
short_description: Streamlit template space
|
| 12 |
---
|
| 13 |
-
# π³ Credit Card Fraud Detection
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
π
|
|
|
|
| 18 |
|
| 19 |
---
|
| 20 |
|
| 21 |
## π Problem
|
| 22 |
|
| 23 |
-
Credit card fraud detection is a highly imbalanced classification problem where fraudulent transactions represent a very small
|
| 24 |
|
| 25 |
-
The goal is to
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
---
|
| 28 |
|
| 29 |
## π Dataset
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
---
|
| 37 |
|
| 38 |
-
##
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
---
|
| 45 |
|
| 46 |
-
##
|
| 47 |
|
| 48 |
### π Prediction
|
|
|
|
| 49 |
- Manual transaction input
|
| 50 |
- Random transaction generator
|
| 51 |
- Fraud probability score
|
| 52 |
-
-
|
|
|
|
| 53 |
|
| 54 |
### π Model Insights
|
|
|
|
| 55 |
- ROC Curve
|
| 56 |
- Confusion Matrix
|
| 57 |
-
-
|
|
|
|
| 58 |
|
| 59 |
---
|
| 60 |
|
| 61 |
-
##
|
| 62 |
|
| 63 |
- Python
|
| 64 |
- Scikit-learn
|
|
@@ -68,17 +111,27 @@ The goal is to correctly identify fraudulent transactions while minimizing false
|
|
| 68 |
|
| 69 |
---
|
| 70 |
|
| 71 |
-
##
|
| 72 |
|
| 73 |
- Handling imbalanced datasets
|
| 74 |
-
-
|
| 75 |
-
-
|
| 76 |
-
-
|
|
|
|
| 77 |
|
| 78 |
---
|
| 79 |
|
| 80 |
-
## π
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
pip install -r requirements.txt
|
| 84 |
-
streamlit run src/streamlit_app.py
|
|
|
|
| 10 |
pinned: false
|
| 11 |
short_description: Streamlit template space
|
| 12 |
---
|
| 13 |
+
# π³ Credit Card Fraud Detection
|
| 14 |
|
| 15 |
+
Real-time fraud detection using Machine Learning and an interactive Streamlit dashboard.
|
| 16 |
|
| 17 |
+
## π Live App
|
| 18 |
+
π [HuggingFace Space link]
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
## π Problem
|
| 23 |
|
| 24 |
+
Credit card fraud detection is a highly imbalanced classification problem where fraudulent transactions represent a very small fraction of the data.
|
| 25 |
|
| 26 |
+
The goal is to:
|
| 27 |
+
|
| 28 |
+
- Detect fraudulent transactions
|
| 29 |
+
- Minimize false negatives
|
| 30 |
+
- Provide real-time predictions
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
## π Dataset
|
| 35 |
|
| 36 |
+
Source: Kaggle β Credit Card Fraud Detection
|
| 37 |
+
|
| 38 |
+
### Features
|
| 39 |
+
|
| 40 |
+
The dataset contains:
|
| 41 |
+
|
| 42 |
+
- **Time** β seconds since first transaction
|
| 43 |
+
- **Amount** β transaction value
|
| 44 |
+
- **V1 β V28** β PCA-transformed anonymized features
|
| 45 |
+
|
| 46 |
+
### π Why PCA?
|
| 47 |
+
|
| 48 |
+
The original transaction data contains sensitive financial information.
|
| 49 |
+
|
| 50 |
+
To preserve privacy:
|
| 51 |
+
|
| 52 |
+
- All original features were transformed using **Principal Component Analysis (PCA)**
|
| 53 |
+
- The resulting components are labeled **V1βV28**
|
| 54 |
+
|
| 55 |
+
These components:
|
| 56 |
+
|
| 57 |
+
- Are **not directly interpretable**
|
| 58 |
+
- Capture the **underlying transaction patterns**
|
| 59 |
+
- Retain the information needed for fraud detection
|
| 60 |
+
|
| 61 |
+
In other words:
|
| 62 |
+
|
| 63 |
+
> V1βV28 are orthogonal principal components representing the variance of the original feature space while ensuring data anonymization.
|
| 64 |
|
| 65 |
---
|
| 66 |
|
| 67 |
+
## π§ Model
|
| 68 |
|
| 69 |
+
Baseline model trained using:
|
| 70 |
+
|
| 71 |
+
- Scaled features
|
| 72 |
+
- Train/test split
|
| 73 |
+
- ROC-AUC evaluation
|
| 74 |
+
|
| 75 |
+
### Evaluation Metric
|
| 76 |
+
|
| 77 |
+
ROC-AUC was used because:
|
| 78 |
+
|
| 79 |
+
- The dataset is highly imbalanced
|
| 80 |
+
- Accuracy is misleading
|
| 81 |
+
- AUC measures class separability
|
| 82 |
|
| 83 |
---
|
| 84 |
|
| 85 |
+
## π― Streamlit App Features
|
| 86 |
|
| 87 |
### π Prediction
|
| 88 |
+
|
| 89 |
- Manual transaction input
|
| 90 |
- Random transaction generator
|
| 91 |
- Fraud probability score
|
| 92 |
+
- Adjustable decision threshold
|
| 93 |
+
- Downloadable prediction report
|
| 94 |
|
| 95 |
### π Model Insights
|
| 96 |
+
|
| 97 |
- ROC Curve
|
| 98 |
- Confusion Matrix
|
| 99 |
+
- AUC score
|
| 100 |
+
- Feature importance (tree-based models)
|
| 101 |
|
| 102 |
---
|
| 103 |
|
| 104 |
+
## βοΈ Tech Stack
|
| 105 |
|
| 106 |
- Python
|
| 107 |
- Scikit-learn
|
|
|
|
| 111 |
|
| 112 |
---
|
| 113 |
|
| 114 |
+
## π§ What I Learned
|
| 115 |
|
| 116 |
- Handling imbalanced datasets
|
| 117 |
+
- Why ROC-AUC is better than accuracy for fraud detection
|
| 118 |
+
- Feature scaling impact
|
| 119 |
+
- Threshold tuning for business use-cases
|
| 120 |
+
- Building ML dashboards for real-time inference
|
| 121 |
|
| 122 |
---
|
| 123 |
|
| 124 |
+
## π Future Improvements
|
| 125 |
+
|
| 126 |
+
- SMOTE / class weighting
|
| 127 |
+
- XGBoost / LightGBM
|
| 128 |
+
- SHAP explainability
|
| 129 |
+
- Real-time API deployment
|
| 130 |
+
|
| 131 |
+
---
|
| 132 |
+
|
| 133 |
+
## π€ Author
|
| 134 |
+
|
| 135 |
+
Beyza Topbas
|
| 136 |
|
| 137 |
+
Machine Learning Portfolio Project
|
|
|
|
|
|