Upload README_space.md
Browse files- README_space.md +53 -0
README_space.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# π³ Credit Card Fraud Detection β HF Space (Calibrated RF Model)
|
| 3 |
+
|
| 4 |
+
This is an interactive **Gradio demo** of a calibrated Random Forest model for credit card fraud detection.
|
| 5 |
+
The model was trained on the [Kaggle Credit Card Fraud dataset](https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud),
|
| 6 |
+
and probability calibration ensures reliable decision thresholds for business scenarios.
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
## π How to Use
|
| 11 |
+
1. **Upload your CSV** with transaction rows.
|
| 12 |
+
- Required columns: `V1` β¦ `V28`, `Amount`
|
| 13 |
+
- Either include engineered features, or just add `Time` (seconds from start)
|
| 14 |
+
β the app will automatically derive:
|
| 15 |
+
- `_log_amount`
|
| 16 |
+
- `Hour_from_start_mod24`
|
| 17 |
+
- `is_night_proxy`
|
| 18 |
+
- `is_business_hours_proxy`
|
| 19 |
+
|
| 20 |
+
2. **Adjust the decision threshold** with the slider.
|
| 21 |
+
- Default is set to the validation threshold for **Precision β₯90%** (`β0.712`).
|
| 22 |
+
- Move it left/right to trade off between precision and recall.
|
| 23 |
+
|
| 24 |
+
3. **Preview results** (first 50 rows) or enable **Return all rows** for the full file.
|
| 25 |
+
- Each row includes:
|
| 26 |
+
- `Fraud_Probability`
|
| 27 |
+
- `Prediction (0 = normal, 1 = fraud)`
|
| 28 |
+
|
| 29 |
+
4. **Download results** as `predictions.csv`.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## π§ͺ Try with Example Data
|
| 34 |
+
You donβt need to bring your own data to test the app!
|
| 35 |
+
Just click **Use Example** inside the app, and it will load the included `example_transactions.csv`.
|
| 36 |
+
|
| 37 |
+
This file mimics the required structure:
|
| 38 |
+
- 60 transactions
|
| 39 |
+
- Columns: `V1..V28`, `Amount`, `Time`
|
| 40 |
+
- Probabilities + predictions are generated live with the same calibrated RF model.
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## π Notes
|
| 45 |
+
- The model is calibrated with **Isotonic Regression** for probability reliability.
|
| 46 |
+
- Default threshold corresponds to **Precision β₯90%**, aligning with fraud detection team priorities.
|
| 47 |
+
- For production use, re-tune thresholds regularly as data drift changes prevalence and costs.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## π Related
|
| 52 |
+
- [Model repo on Hugging Face Hub](https://huggingface.co/TarekMasryo/CreditCard-fraud-detection-ML)
|
| 53 |
+
- [Original Kaggle dataset](https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud)
|