Skip to content

Containerized FastAPI service that predicts fraudulent credit card transactions using a trained machine learning model

Notifications You must be signed in to change notification settings

MahmoodAbdali79/fraud-detection-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ Credit Card Fraud Detection API

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

  • Dataset: Credit Card Fraud Detection
  • Number of records: 284,807 transactions
  • Class distribution: Highly imbalanced (Class 1 ≈ 0.17%)

🧠 Model Performance (XGBoost)

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

🧠 Project Features

  • ✅ 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

🚀 Running the Project

Clone the repository

git clone https://github.com/MahmoodAbdali79/fraud-detection-api.git
cd fraud-detection-api

Run locally

pip install -r requirements.txt
python -m web.main

Run with Docker

docker build -t fraud-api .
docker run -p 8000:8000 fraud-api

Access API

curl -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.

About

Containerized FastAPI service that predicts fraudulent credit card transactions using a trained machine learning model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published