Skip to content

PalaniappanR02/GovShield-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ GovShield — AI-Powered Government Fraud Detection Platform

Pod.ai Submission | April 2026
Lead Data Scientist Review Version | Classification: INTERNAL


📋 Overview

GovShield is a production-grade, AI-powered fraud detection system designed for government procurement auditing. It combines a Hybrid Ensemble (XGBoost + MLP) with SMOTE class balancing and SHAP explainability into a fully interactive Streamlit dashboard.

Component Technology
Frontend Streamlit + Glassmorphism CSS
Gradient Boosting XGBoost 2.0
Deep Learning Keras MLP (256→128→64)
Class Balancing SMOTE (imbalanced-learn)
Explainability SHAP TreeExplainer
Visualisation Plotly

🚀 How to Run

Prerequisites

  • Python 3.10 or higher
  • pip package manager
  • ~4 GB RAM recommended (for MLP training + SHAP computation)

Step 1 — Clone / Download the Project

# Option A: clone if hosted on git
git clone https://github.com/your-org/govshield.git
cd govshield

# Option B: navigate to your local directory
cd "d:\Palani\My creativity\GovAI"

Step 2 — Create a Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate on Windows
venv\Scripts\activate

# Activate on Linux / macOS
source venv/bin/activate

Step 3 — Install Dependencies

pip install -r requirements.txt

⏱️ First install may take 3–7 minutes due to TensorFlow and XGBoost downloads.


Step 4 — Verify the Logo File

Ensure GovShield_Logo.jpg is in the same directory as app.py:

GovAI/
├── app.py
├── GovShield_Logo.jpg   ✅ required
├── requirements.txt
└── README.md

Step 5 — Launch the Application

streamlit run app.py

The app will open automatically in your default browser at:

http://localhost:8501

🔄 First load takes ~60–90 seconds while:

  • Generating 50,000 synthetic procurement records
  • Applying SMOTE oversampling
  • Training XGBoost (300 estimators)
  • Training MLP (256-128-64, early stopping)
  • Caching all results (subsequent reloads are instant)

Step 6 — Using the Application

Sidebar Controls

Control Description
Fraud Base Rate Adjust synthetic dataset imbalance (default: 1%)
Dataset Size Choose 10K / 25K / 50K records
Decision Threshold Fraud probability cutoff (default: 0.5)

Tab 1 — 📊 Analytics Dashboard

  • Density Heatmap: Fraud vs legitimate case clustering in Risk/Deviation space
  • Feature Distributions: Per-feature histograms comparing fraud and legitimate patterns
  • Probability Distribution: Ensemble score separation on the test set

Tab 2 — 🧠 Neural Engine

  • Set procurement case parameters using sliders
  • Click "🚀 Run Analysis" to trigger the Hybrid Ensemble
  • View the Risk Meter (Green → Yellow → Red gauge)
  • See XGBoost, MLP, and Ensemble scores separately

Tab 3 — 🔍 Audit Transparency

  • Select any high-risk case from the dropdown
  • View Top 5 Red Flag Contributors (SHAP bar chart)
  • Understand per-feature contribution to the fraud score
  • Review Global Feature Importance across all test cases

🏗️ Technical Architecture

SMOTE Class Balancing

Training Data Split:
  Original: 40,000 records (99% legit, 1% fraud = 400 fraud cases)
  After SMOTE: 79,600 records (50% legit, 50% fraud)
  
SMOTE generates synthetic fraud cases by interpolating between real fraud
samples and their k=5 nearest fraud neighbors in feature space.

Hybrid Ensemble

Input Features (12) → StandardScaler
         │
    ┌────┴────┐
    │         │
XGBoost     Keras MLP
(n=300)   256→128→64→sigmoid
    │         │
    └────┬────┘
         │
   Average Probability
         │
   Fraud Score [0-1]

SHAP Explainability

XGBoost Model → TreeExplainer → SHAP Values per case
                                       │
                          ┌────────────┼────────────┐
                    Feature 1      Feature 2    Feature 3
                    (contribution) (contribution)(contribution)
                          │
                    Top 5 Red Flag Bar Chart

📁 Project Structure

GovAI/
├── app.py                # Main Streamlit application
├── GovShield_Logo.jpg    # Brand logo (sidebar + header)
├── requirements.txt      # Pinned library versions
└── README.md             # This file

⚙️ Configuration

All model parameters are configurable via the Sidebar UI at runtime. For programmatic override, edit these constants in app.py:

# Dataset
n_samples   = 50_000       # Total synthetic records
fraud_ratio = 0.01         # 1% base fraud rate

# XGBoost
n_estimators = 300
max_depth    = 6
learning_rate = 0.05

# MLP
epochs        = 30
batch_size    = 512
dropout_rate  = 0.3        # Layers 1 & 2
dropout_rate2 = 0.2        # Layer 3

🔬 Model Performance (Typical Results)

Results vary slightly due to stochastic MLP training.

Metric Value
ROC-AUC ~0.97–0.99
Fraud Precision ~0.78–0.88
Fraud Recall ~0.82–0.92
Accuracy ~0.99

📦 Key Dependencies

Package Version Purpose
streamlit 1.34.0 Web dashboard framework
xgboost 2.0.3 Gradient boosted trees
tensorflow 2.16.1 MLP neural network
imbalanced-learn 0.12.3 SMOTE resampling
shap 0.45.1 Model explainability
plotly 5.22.0 Interactive charts
scikit-learn 1.4.2 Preprocessing, metrics

🛡️ Notes for Lead Data Scientist Review

  1. Data Leakage Prevention: StandardScaler is fit only on training data; SMOTE is applied only on training data. The test set is held completely clean.
  2. SHAP Computation: TreeExplainer uses the XGBoost component (exact Shapley values). MLP SHAP would require a KernelExplainer (slower) — available on request.
  3. Caching Strategy: @st.cache_data on data generation and @st.cache_resource on models ensures single training per session.
  4. Thread Safety: n_jobs=-1 on XGBoost uses all CPU cores. Reduce if running in a single-threaded pod.

GovShield v2.0 — © 2026 Government AI Division | Pod.ai Submission

About

Fraud Detection in Government Schemes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages