A production-ready, containerized FastAPI service that predicts fraudulent credit card transactions using a trained machine learning model (e.g., XGBoost, Logistic Regression, etc.).
- Dataset: Credit Card Fraud Detection
- Number of records: 284,807 transactions
- Class distribution: Highly imbalanced (
Class 1≈ 0.17%)
Validation Report:
| Metric | Class 0 (Non-Fraud) | Class 1 (Fraud) |
|---|---|---|
| Precision | 0.9997 | 0.8737 |
| Recall | 0.9998 | 0.8469 |
| F1-Score | 0.9998 | 0.8601 |
Accuracy: 99.95%
Confusion Matrix:
| Predicted Not Fraud | Predicted Fraud
Not Fraud | 56852 | 12
Fraud | 15 | 83
- ✅ Pretrained model selection based on highest F1-score
- ✅ Input validation with Pydantic
- ✅ Preprocessing pipeline before prediction
- ✅ Dockerized for deployment
- ✅ Testing with
pytest - ✅ Real API testing using
requests
git clone https://github.com/MahmoodAbdali79/fraud-detection-api.git
cd fraud-detection-apipip install -r requirements.txt
python -m web.maindocker build -t fraud-api .
docker run -p 8000:8000 fraud-apicurl -X 'POST' \
'http://0.0.0.0:8080/predict' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"features":
{"Time":53937.0,
"V1":-2.0426081994,
"V2":1.5735780737,
"V3":-2.3726524327,
...
}the input data is not complete. find complete inpute data there.