A Python/Streamlit application that predicts fraud risk for mobile-money (M-Pesa-style) transactions in real time, built as a third-year Computer Science project (Fintech / AI-ML domain, Kenya context).
# Mobile Money Fraud Detection System
A Python/Streamlit application that predicts fraud risk for mobile-money
(M-Pesa-style) transactions in real time, built as a third-year Computer
Science project (Fintech / AI-ML domain, Kenya context).
## Problem It Solves
Mobile money fraud in Kenya — SIM-swap account takeover, agent-till fraud,
and "reversal scam" social engineering — currently relies mostly on manual,
after-the-fact reporting. This system scores each transaction in real time
using a Random Forest classifier trained on behavioral red flags (SIM/device
change, receiver novelty, location deviation, transaction velocity, timing,
and amount), so high-risk transactions can be flagged **before** money moves.
## Project Structure
```
fraud_app/
├── train_model.py # Generates synthetic data + trains the model
├── app.py # Streamlit dashboard (the "app")
├── requirements.txt # Python dependencies
├── fraud_model.joblib # Trained model (generated by train_model.py)
├── transactions_sample.csv # Synthetic dataset (generated by train_model.py)
└── README.md
```
## Setup & Running
1. **Install dependencies** (Python 3.10+ recommended):
```bash
pip install -r requirements.txt
```
2. **Train the model** (only needed once, or whenever you want to regenerate
the dataset/model):
```bash
python train_model.py
```
This creates `fraud_model.joblib` and `transactions_sample.csv`.
3. **Launch the dashboard:**
```bash
streamlit run app.py
```
Then open the URL Streamlit prints (usually `
localhost`).
## Using the App
- **Prediction tab:** Enter transaction details in the sidebar (amount, time,
transaction type, receiver novelty, SIM/device-change flag, location
deviation) and click **Analyze Transaction** to get a fraud risk score and
a plain-English breakdown of which red flags triggered it.
- **Fraud Analytics tab:** Explore the training dataset — fraud rate by hour,
by transaction type, by SIM/device-change status …