|
|
--- |
|
|
sdk: streamlit |
|
|
sdk_version: 1.51.0 |
|
|
license: apache-2.0 |
|
|
--- |
|
|
# π³ Credit Card Fraud Detection Dashboard |
|
|
|
|
|
[](https://streamlit.io/)\ |
|
|
[](DATA_LICENSE)\ |
|
|
[](https://github.com/tarekmasryo) |
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
## π Overview |
|
|
|
|
|
Interactive dashboard built with **Streamlit, Plotly, and Scikit-learn** for real-time **fraud detection analysis**. |
|
|
It demonstrates a **business-aware ML pipeline** on the classic **Credit Card Fraud Dataset** (284,807 transactions, only 492 frauds β 0.17%). |
|
|
|
|
|
- π Upload your own transaction CSV or use the built-in dataset |
|
|
- βοΈ Custom decision thresholds with cost-sensitive analysis |
|
|
- π Confusion matrix, ROC/PR curves, and costβthreshold visualization |
|
|
- π‘ Permutation feature importance for interpretability |
|
|
- π§Ύ Segmented performance profiling (by amount, time of day, etc.) |
|
|
|
|
|
--- |
|
|
|
|
|
## π Dashboard Preview |
|
|
|
|
|
### Data Overview |
|
|
 |
|
|
|
|
|
### Prediction Engine |
|
|
 |
|
|
|
|
|
### Model Metrics |
|
|
 |
|
|
|
|
|
### Model Insights |
|
|
 |
|
|
|
|
|
### Data Quality & Segments |
|
|
 |
|
|
|
|
|
--- |
|
|
|
|
|
## π Features |
|
|
|
|
|
- **Models**: RandomForest & XGBoost (calibrated) |
|
|
- **Presets**: Strict / Balanced / Lenient thresholds |
|
|
- **Threshold Finder**: auto-select by target Precision/Recall |
|
|
- **Cost Analysis**: business-aligned FP vs FN costs |
|
|
- **Visuals**: Confusion matrix, ROC, PR, cost vs threshold curves |
|
|
- **Insights**: Permutation importance, segmented KPIs |
|
|
- **Data Handling**: automatic schema validation + engineered features (`log(Amount)`, business hours, night proxy) |
|
|
|
|
|
--- |
|
|
|
|
|
## π Run Locally |
|
|
|
|
|
Clone the repo and install requirements: |
|
|
|
|
|
```bash |
|
|
git clone https://github.com/tarekmasryo/fraud-detection-dashboard.git |
|
|
cd fraud-detection-dashboard |
|
|
pip install -r requirements.txt |
|
|
``` |
|
|
|
|
|
Run the app: |
|
|
|
|
|
```bash |
|
|
streamlit run app.py |
|
|
``` |
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
## βοΈ Deploy on Hugging Face Spaces |
|
|
|
|
|
This repository is ready to be deployed as a **Streamlit Space** on [Hugging Face](https://huggingface.co/spaces). |
|
|
Make sure to include the following files in your repo: |
|
|
|
|
|
- `app.py` β main app file |
|
|
- `requirements.txt` β Python dependencies |
|
|
- `artifacts/` β trained model `.joblib` files and `thresholds.json` |
|
|
- `data/creditcard.csv` (optional, for default dataset) |
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
## π License & Attribution |
|
|
|
|
|
- **Data** β Original [Credit Card Fraud Dataset](https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud) |
|
|
Licensed under **CC BY-NC 4.0** β for research & educational use only. |
|
|
|
|
|
--- |
|
|
|
|
|
## Related Repositories |
|
|
- π [Fraud Detection EDA + Baseline Models](https://github.com/tarekmasryo/creditcard-fraud-detection) |