Nabil ShehadehAll Projects
Data Science · Machine Learning · FinTech

Credit Card Fraud Detection System

A production-ready machine learning system that detects fraudulent credit card transactions in real-time. Combines advanced feature engineering, a six-model ensemble, and a FastAPI service delivering sub-100ms predictions with SHAP-based explainability.

View on GitHub
Key Achievements
0.951
ROC-AUC
ensemble model
0.871
PR-AUC
primary metric (imbalanced)
50+
Engineered Features
behavioral & temporal
<100ms
Prediction Latency
FastAPI service
Interactive Dashboard

Simulated real-time fraud detection — transactions stream live and model performance metrics are shown below.

Live Transaction Feed
ATM·$30.15·UK
10:53:50 PMRisk: 0.258
LEGIT
Gas Station·$220.02·UK
10:53:50 PMRisk: 0.037
LEGIT
Restaurant·$840.17·DE
10:53:50 PMRisk: 0.079
LEGIT
Walmart·$927.85·US
10:53:50 PMRisk: 0.303
LEGIT
Gas Station·$1927.52·CN
10:53:50 PMRisk: 0.011
LEGIT
Online Transfer·$339.31·US
10:53:50 PMRisk: 0.299
LEGIT
ATM·$1089.82·CN
10:53:50 PMRisk: 0.194
LEGIT
Walmart·$720.40·CN
10:53:50 PMRisk: 0.932
FRAUD
Walmart·$1559.46·UK
10:53:50 PMRisk: 0.303
LEGIT
Restaurant·$1451.08·BR
10:53:50 PMRisk: 0.051
LEGIT
ATM·$1383.12·UK
10:53:50 PMRisk: 0.891
FRAUD
Gas Station·$64.12·BR
10:53:50 PMRisk: 0.303
LEGIT

0.871

PR-AUC (Ensemble)

primary metric

0.951

ROC-AUC

ensemble model

<100ms

Prediction Speed

per transaction

50+

Features Engineered

behavioral + temporal

Model Comparison

Performance across all 6 algorithms

Log. Reg.Rand. ForestLightGBMXGBoostAutoencoderEnsemble0.00.30.50.81.0

ROC Curve — Ensemble Model

True Positive Rate vs. False Positive Rate (AUC = 0.951)

00.020.050.10.20.350.50.751FPR00.250.50.751TPR
Performance Results

All models evaluated on held-out test set. Ensemble achieves best trade-off for deployment.

ModelPR-AUCROC-AUCPrecision@100Recall@100
Logistic Regression0.7420.8910.230.45
Random Forest0.8230.9340.280.61
LightGBM0.8560.9430.310.67
XGBoost0.8410.9380.290.64
Autoencoder0.6230.7890.180.34
Ensemble0.8710.9510.350.72
System Features

Real-Time Prediction API

FastAPI service delivers sub-100ms fraud scores per transaction with single and batch prediction endpoints.

Ensemble ML Models

Six algorithms — Logistic Regression, Random Forest, LightGBM, XGBoost, Autoencoder, and a stacking ensemble — for robust detection.

Advanced Feature Engineering

50+ engineered features covering behavioral velocity, temporal patterns, rolling statistics, and PCA anomaly scores.

Explainable Predictions

SHAP-based feature importance surfaces the top drivers of each fraud score for analyst review and compliance.

Docker & CI/CD

Fully containerized with Docker Compose and an automated GitHub Actions pipeline for testing, linting, and deployment.

Comprehensive Testing

Unit and integration tests with 80%+ coverage target, mock fixtures, and a full pipeline integration test suite.

Detection Models

Six algorithms provide complementary coverage across different fraud patterns, combined in a stacking ensemble.

01

Logistic Regression

Baseline classifier

Class-weighted logistic regression provides a fast, interpretable baseline with strong recall on imbalanced fraud data.

02

Random Forest

Ensemble of decision trees

Aggregates hundreds of trees to reduce variance and capture non-linear feature interactions in transaction behavior.

03

LightGBM

Gradient boosting (best single model)

Leaf-wise boosting with hyperparameter tuning achieves the highest single-model PR-AUC (0.856) with fast inference.

04

XGBoost

Gradient boosting with early stopping

Regularized boosting with early stopping prevents overfitting while maintaining competitive recall on rare fraud events.

05

Autoencoder

Unsupervised anomaly detection

Learns a compressed representation of normal transactions; high reconstruction error flags novel fraud patterns unseen in training.

06

Stacking Ensemble

Meta-learner combination

A meta-learner combines all five base model outputs to achieve PR-AUC 0.871 and ROC-AUC 0.951 — the best overall performance.

Pipeline Architecture
01

Ingest

CSV transaction data (V1–V28 PCA features + Amount + Time) loaded and validated via Pydantic schemas

02

Engineer

50+ features extracted: velocity, temporal cycles, rolling z-scores, isolation forest anomaly scores, interaction ratios

03

Predict

Six ML models score each transaction; ensemble meta-learner combines outputs into a single calibrated fraud probability

04

Explain

SHAP values surface top feature contributions per prediction for analyst review, compliance, and model monitoring

Skills Demonstrated
Imbalanced classification (SMOTE, class weights)Feature engineering & behavioral analyticsEnsemble methods & model stackingExplainability with SHAPFastAPI REST service developmentDocker containerization & CI/CDModel evaluation on skewed datasets
Technologies Used
Pythonscikit-learnLightGBMXGBoostFastAPISHAPPandasNumPyDockerGitHub ActionsPytestPydanticJupyterCICIDS2017 / Kaggle
Nabil Shehadeh · nshehadeh@usc.edu2026