FraudShield AI
Real-time fraud scoring that turns a 6.86M-transaction dataset into a single API call.
Fraud detection has to be fast, rare-event-aware, and explainable.
Financial fraud detection needs to run in real time on high-volume transaction data, catch rare fraud events without drowning legitimate users in false positives, and be explainable enough for a human reviewer to trust a block decision rather than treat the model as a black box.
A scored, explained decision — not just a number.
An XGBoost model trained on the full 6.86-million-row PaySim dataset, wrapped in a FastAPI service that returns a fraud probability, a decision, and a short AI-generated explanation of which features actually drove the score — grounded in computed SHAP values, not free-text guessing.
XGBoost over a deep learning model
PaySim's features are already engineered and tabular; gradient boosting matches or beats deep nets on tabular fraud data while training and serving far faster, with feature importances that map directly onto SHAP explanations.
imbalanced-learn instead of naive oversampling
Fraud is roughly 0.1% of transactions. Naive duplication would overfit to a handful of copied fraud cases, so the class imbalance is corrected during training instead of by inflating the minority class.
Deployed threshold picked by F1, not 0.5
At a threshold of 0.984, the model trades a small amount of recall for a large drop in false positives — chosen deliberately over a cost-based alternative (~0.66) that would have flagged far more legitimate transactions.
A feature that looked like leakage — but wasn't
One engineered feature (would_drain_orig) dominated importance at 57%, which is exactly the shape a leaked label would take. It had to be specifically audited with a verification script to confirm it was legitimate signal — the transaction would in fact have drained the origin account — not a leak of the fraud label itself.
Getting to real numbers, not placeholders
Earlier iterations carried stale metrics and a hardcoded 0.5 threshold. Running the full 6.86M-row dataset through the fixed pipeline and updating every reported number — README, in-app About tab, badges — was its own pass of work, separate from the modeling itself.
The model scores; a separate step explains.
The real-time API validates the request schema, runs the XGBoost model, computes a SHAP-based feature-importance breakdown, and passes those computed numbers — not raw predictions — to a small AI call that turns them into a plain-language risk explanation. The model never explains itself in free text directly, which keeps the explanation grounded in numbers that were actually computed.