End-to-End Fraud Detection API
This project is a complete, end-to-end machine learning application that detects fraudulent credit card transactions. It includes data preprocessing, model training, and a containerized Flask API for serving real-time predictions.
Features
Data Preprocessing: Handles class imbalance using the SMOTE (Synthetic Minority Over-sampling Technique).
Machine Learning Model: Utilizes a powerful XGBoost classifier for high-performance fraud detection.
Web API: A simple Flask API endpoint to serve predictions.
Containerization: Packaged with Docker for easy deployment and portability.
Technologies Used
Python
Pandas
Scikit-learn
XGBoost
Imbalanced-learn
Flask
Gunicorn
Docker
Getting Started
Prerequisites
Git
Docker Desktop
Installation & Running the Application
Clone the repository:
Bash
git clone https://github.com/vinayakkamatcodes/fraud_detection.git cd fraud_detection
Build the Docker image: Bash
docker build -t fraud-api .
Run the Docker container: Bash
docker run -p 5000:8080 fraud-api
The API will now be running and accessible at http://127.0.0.1:5000.
API Endpoint
/predict
Method: POST
Description: Predicts if a given transaction is fraudulent.
Request Body: A JSON object containing the 30 features of the transaction.
Example Request Body: JSON
{ "Time": 406.0, "V1": -2.31, "V2": 1.95, "V3": -1.61, "V4": 3.99, "V5": -0.52, "V6": -1.43, "V7": -2.54, "V8": 1.39, "V9": -2.77, "V10": -2.77, "V11": 3.20, "V12": -2.90, "V13": -0.59, "V14": -4.28, "V15": 0.38, "V16": -1.14, "V17": -2.83, "V18": -0.01, "V19": 0.41, "V20": 0.12, "V21": 0.51, "V22": 0.93, "V23": 0.21, "V24": -0.08, "V25": 0.14, "V26": -0.54, "V27": 0.03, "V28": -0.06, "Amount": 0.00 }
Success Response: A JSON object indicating the prediction.
{"is_fraud": 1}: The transaction is predicted to be fraudulent.
{"is_fraud": 0}: The transaction is predicted to be legitimate.