Machine Learning REST API for detecting fraudulent financial transactions in real-time.
348
This image provides a production-ready, containerized Machine Learning REST API for detecting fraudulent financial transactions in real-time.
Built using FastAPI and an optimized XGBoost model trained on the Xente Fintech dataset (Mobile Money/E-commerce), this microservice evaluates incoming transaction payloads, applies custom Scikit-Learn behavioral feature engineering, and returns a probability score and fraud classification in milliseconds.
The underlying model was specifically engineered to handle high-cardinality categorical data and extreme class imbalance (AUPRC: 0.842, False Positive Rate: 0.094%), ensuring high recall with minimal friction to legitimate customers.
python:3.10-slim1. Pull the image:
docker pull jaybee123/xente-fraud-api:latest
2. Run the container:
docker run -d --name fraud-api -p 8000:8000 jaybee123/xente-fraud-api:latest
3. Access the API: Once running, the interactive Swagger UI documentation is automatically available at: š http://localhost:8000/docsā
GET /testA built-in testing endpoint that runs a dummy transaction through the loaded MLflow model to verify inference integrity.
POST /predictThe primary inference endpoint. It expects a JSON payload containing the raw transaction parameters. The internal Scikit-Learn transformer automatically extracts temporal and behavioral velocity features on the fly.
Example cURL Request:
curl -X 'POST' \
'http://localhost:8000/predict' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"TransactionId": "TransactionId_51888",
"CustomerId": "CustomerId_1",
"ProviderId": "ProviderId_4",
"ProductId": "ProductId_10",
"ProductCategory": "airtime",
"ChannelId": "ChannelId_2",
"Amount": -10000.0,
"Value": 10000.0,
"TransactionStartTime": "2018-11-21T16:49:14Z",
"PricingStrategy": 4
}'
Example JSON Response:
{
"transaction_id": "TransactionId_51888",
"Product_Category": "airtime",
"fraudResult": false,
"fraud_probability": 0.00004561
}
The container exposes port 8000 by default. It natively contains the compiled MLflow model artifacts and the custom Scikit-Learn transformer class required for deserialization.
This container is built and pushed automatically via GitHub Actions CI/CD pipelines. For the complete MLOps architecture, exploratory data analysis, and model training scripts, please visit the source repository:
Content type
Image
Digest
sha256:63260fd3eā¦
Size
864.3 MB
Last updated
4 months ago
docker pull jaybee123/xente-fraud-api