Logo Lanfrica

AmmonBelyon/fraud-detection-kenya

Domain:

socioeconomic

Record type:

software
Creator:
Amm
Host:
End-to-end financial fraud detection for M-Pesa, bank, and KRA transactions β€” XGBoost + SMOTE on synthetic Kenyan data, with a live Streamlit demo. # πŸ›‘οΈ FraudShield Kenya β€” Financial Fraud Detection with XGBoost + SMOTE An end-to-end machine learning pipeline that detects financial fraud across **M-Pesa mobile money**, **bank account transactions**, and **KRA tax filings** using synthetic Kenyan financial data. Handles extreme class imbalance (fraud 8` | | **Large unusual** | Single amount far above norm | `ratio_to_avg_amount > 12` | | **Account takeover** | New device + location + large transfer | `new_device + location_mismatch` | | **KRA evasion** | Declared income far below expected | `declared_vs_expected_ratio < 0.15` | | **Structuring** | Just-below-threshold transactions (AML) | `amount β‰ˆ KES 99,000` | --- ## Key Features Engineered ```python ratio_to_avg_amount # Is this transaction 10x larger than their normal? velocity_score # (txns_last_hour Γ— 3) + txns_last_day risk_score # Composite: ratio + device + location + time signals tax_risk # (1 - declared_ratio) + (days_late / 365) account_maturity # log(account_age_days) β€” newer accounts riskier is_night # Transactions between midnight and 5 AM ``` --- ## Results | Model | ROC-AUC | Avg Precision | F1 (Fraud) | |---|---|---|---| | XGBoost | **1.0000** | **1.0000** | **0.9934** | | LightGBM | **1.0000** | **1.0000** | **0.9934** | *Note: High AUC reflects strong synthetic signal injection. Real-world performance will vary.* --- ## Project Structure ``` fraud_detection/ β”œβ”€β”€ 1_generate_data.py # Synthetic data generator (Faker + Kenyan context) β”œβ”€β”€ 2_train_model.py # SMOTE + XGBoost + LightGBM + SHAP β”œβ”€β”€ 3_app.py # Streamlit live demo β”œβ”€β”€ data/ β”‚ β”œβ”€β”€ kenya_fraud_dataset.csv # 50,000 synthetic transactions β”‚ └── test_set.csv # Held-out test set with predictions β”œβ”€β”€ models/ β”‚ β”œβ”€β”€ best_model.pkl # Saved XGBoost model β”‚ └── feature_cols.pkl # Feature column list β”œβ”€β”€ outputs/ β”‚ β”œβ”€β”€ confusion_matrix_xgboost.png β”‚ β”œβ”€β”€ roc_ …