metadata
title: fraud-pattern-detector
emoji: 🕵️
colorFrom: red
colorTo: yellow
sdk: docker
app_port: 7860
pinned: false
Fraud Pattern Detector (XGBoost + Network Patterns) — FastAPI + Streamlit
Fraud detection demo trained on Kaggle's IEEE-CIS Fraud Detection dataset.
What you get
- XGBoost baseline with compact feature engineering
- Per-transaction explanations (SHAP-style drivers)
- Lightweight transaction-network view (cluster patterns around shared identifiers)
- FastAPI inference service (
/score) - Streamlit UI with 2 tabs:
- Single transaction scorer
- Network visualization with flagged clusters
- Docker image compatible with Hugging Face Spaces
Local setup
Requires Python 3.11+.
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Download data (Kaggle)
- Place your Kaggle credentials at
~/.kaggle/kaggle.json(recommended), or ensure akaggle.jsonexists in your workspace root. - Ensure you've accepted the competition rules on Kaggle.
python -m scripts.download_data
Train (XGBoost baseline)
python -m scripts.train_xgb --seed 42 --max_rows 200000
Run locally
Terminal 1:
uvicorn app.api:app --host 0.0.0.0 --port 8000
Terminal 2:
streamlit run app/streamlit_app.py --server.port 7860 --server.address 0.0.0.0