-
-
5,000 transactions scanned, 75 flagged, 48 of 50 frauds caught, provides English reasoning for each flag. Increasing threshold will get50/50
-
If I wanted to deploy this site into the real world, all I need to do is buy the plan and boom.
-
One command starts the app locally. Uses Local host and stream lit.
-
Users can upload their own CSV, with a tip showing the exact columns and a downloadable template.
-
Fraud (orange) scores higher than normal transactions (blue), and most of it lands past the dashed alert line.
-
Every flagged transaction gets a score and a English reason. Streamlit organizes transaction by user preference, giving them the option.
Inspiration
Small businesses process hundreds of transactions every week, but unlike giant enterprises, they usually don't have dedicated fraud departments or massive budgets for complex security platforms. A single fraudulent chargeback, a wave of stolen card testings, or a sudden burst of fake refunds can severely disrupt a local store's cash flow. I built Fraud Shield as a solo developer to give small business owners a simple line of defense that detects suspicious transaction patterns automatically without needing years of historical fraud data to train on.
What it does
Fraud Shield is a lightweight, zero setup anomaly detection tool built for small businesses. It features both an interactive, user friendly Streamlit web dashboard and a command line interface. The tool scans transaction logs (via CSV upload), builds personalized behavioral baselines for each customer, automatically flags high risk transactions (such as fake charges, odd hour activity, or rapid fire refunds), and outputs plain English explanations for every single alert so business owners know exactly why a transaction was flagged.
How I built it
Fraud Shield combines a fast Python backend with an intuitive Streamlit UI:
- Streamlit: This web application system that connects backend python to front end UI allows me to constructs multiple feature vectors for each user by tracking key behavioral metrics, including transaction amount, time of day, purchase frequency, and refund rate. I couldn't use vercel app because the UI was different.
- KNN Distance-Based Detection: Applies memory based K-Nearest Neighbors (a concept I mastered at the UT Austin ML Algorithmic Academy) to plot baseline customer behavior and calculate spatial distances across feature coordinates.
- Euclidean Distance Scoring: Quantifies how far a new transaction (
p) strays from a customer's typical baseline (q) using multi variable Euclidean distance:d(p, q) = sqrt( sum( (p_i - q_i)^2 ) ). - Thresholding & Heuristic Explanations: Isolates the top 1% highest distance scores as high risk anomalies and maps raw mathematical variance to clear, human readable explanations (e.g., "5x higher than typical spend").
Learned from UT Austin program.
Challenges I ran into
- The Imbalance Problem: Fraud accounts for a tiny fraction of total transactions (1%). Traditional metrics like raw accuracy are misleading since a model predicting zero fraud would still be 99% accurate. I had to focus strictly on balancing Precision, Recall, and the F1 Score (
F1 = 2 * (Precision * Recall) / (Precision + Recall)). - Interpretable Explanations: Translating vector distances into clear, actionable language for non technical business owners required careful heuristic design.
Accomplishments that I'm proud of
- Successfully deploying an unsupervised ML model solo that achieves strong performance (92% precision on test data) without needing any prior fraud examples to train on.
- Building a dual interface application (Streamlit web app + CLI tool) that allows any small business owner to drop in a CSV export from their payment processor and get instant insights.
What I learned
- Real World Application of ML Concepts: At the UT Austin Machine Learning Algorithmic Academy, I learned how KNN uses memory stored examples to sort coordinates and classify items, much like mapping facial landmarks for emotion recognition. I successfully applied that exact same distance metric foundation to financial feature coordinates to detect transaction anomalies.
What's next for Fraud Shield
- Automated Alerts: Implementing instant SMS or email notifications for business owners when a high risk anomaly is flagged.
Built With
- anomaly
- data
- detection
- fintech
- learning
- machine
- python
- science
- security
- streamlit
- unsupervised