Real-Time Fraud Detection Pipeline
Streaming inference under severe class imbalance
The problem this had to solve.
Study whether an aggressively reduced fraud feature set can preserve ranking quality while lowering inference cost under severe class imbalance.
The project processes a dataset of more than 284,000 transactions with a 577:1 class imbalance through Kafka, Spark Structured Streaming, feature processing, and Spark MLlib inference.
Its benchmarks compare multiple model and feature-selection combinations. A three-feature configuration retained 99.2% of the full-feature AUC-ROC while reducing inference latency by approximately 30%, alongside measured throughput of 3,285 transactions per second and 26.53 ms median batch latency.
Academic collaboration with Aditya Ravi and Atharva Indulkar; the public repository is owned by Aditya Ravi and does not imply sole ownership by Aayush.
Constraints
- The experiment uses the public ULB/Kaggle European cardholder dataset: 284,807 historical transactions and 492 fraud cases.
- Spark runs in local[*] mode and Kafka traffic is simulated by replaying held-out transactions in 100-record micro-batches.
- SMOTE is applied only to the training split; the held-out test set contains 42,722 transactions and 74 fraud cases.
- Reported throughput and latency describe one local experimental setup, not production payment infrastructure.
How the system is put together.
Transaction stream
284K+ transaction project dataset
sourceKafka
Carries the incoming event stream
processSpark Structured Streaming
Processes transactions in streaming batches
processFeature pipeline
Selects 3 features from the 30-feature baseline
processModel inference
Scores transactions using Spark MLlib
decisionFraud score
Emits a scored or flagged transaction state
outputWhat was chosen, and what it cost.
Optimize a compact feature subset
- Choice
- Use a Quantum-Inspired Evolutionary Algorithm with a Random Forest proxy and a parsimony penalty to select three of 30 features.
- Rationale
- The experiment directly tests the quality-versus-inference-cost tradeoff rather than assuming every available feature is required.
- Cost
- The three-feature Random Forest produces far more false positives than the 30-feature baseline: 466 versus 27 on the held-out test set.
Compare search and model combinations
- Choice
- Benchmark all-features, PCA, mutual information, RFE, and QIEA across Logistic Regression, Random Forest, and Gradient Boosted Trees.
- Rationale
- Fifteen combinations expose whether an apparent gain belongs to feature selection, classifier choice, or both.
Keep streaming results separate from model latency
- Choice
- Report per-transaction classifier latency alongside end-to-end simulated micro-batch throughput and latency.
- Rationale
- These measurements describe different boundaries and should not be conflated.
How it was checked.
- A stratified 70/15/15 split and training-only SMOTE were used; the repository reports all 15 feature-selection/classifier results on the held-out test split.
- QIEA + Random Forest achieved AUC-ROC 0.956 versus 0.964 for all-features + Random Forest, retaining 99.2% of that AUC-ROC value with three features.
- The simulated streaming replay processed 42,700 held-out transactions in about 13 seconds: 3,285 transactions/s, 26.53 ms median batch latency, and 49.10 ms p95.

What was measured.
Each figure states the conditions it was measured under. None of them describe production traffic.
3,285/s
transactions processed
Verified streaming throughput from the project benchmark.
26.53 ms
median batch latency
Verified median latency from the streaming benchmark.
99.2%
full-feature AUC-ROC retained
Three selected features compared with the 30-feature baseline.
~30%
lower inference latency
Measured after reducing the feature set from 30 to 3.
Where this stops being true.
- This is a notebook-scale local experiment, not a deployed fraud-detection service or a live Kafka/Spark cluster benchmark.
- AUC-ROC retention masks a material precision tradeoff: QIEA + Random Forest precision is 11.2% versus 69.7% for all-features + Random Forest at the evaluated thresholds.
- The dataset contains anonymised historical European card transactions from a 48-hour period, so external validity and concept drift are untested.
- The repository names three authors but does not document each person's individual contribution.
What it is built with.
Data & evaluation
- Spark MLlib
- NumPy
Infrastructure & providers
- Apache Kafka
- PySpark
- Spark Structured Streaming