Skip to content

Aman763-tech/Smartgov

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmartGov AI

This project is a fraud detection system for government schemes. It uses a RandomForestClassifier to detect potential fraud based on applicant data and serves predictions via a FastAPI backend.

Structure

  • data/: Contains the synthetic dataset (fraud_dataset.csv).
  • models/: Stores the trained machine learning model (fraud_model.pkl).
  • backend/: Contains the FastAPI application (main.py).
  • frontend/: Directory reserved for the frontend web application (currently empty as requested).
  • utils/: Contains utility scripts:
    • generate_data.py: Script to generate the 300-row synthetic dataset.
    • train_model.py: Script to train the RandomForestClassifier on the generated data.

Getting Started

1. Install Dependencies

Make sure you have Python installed. Install the required packages:

pip install -r requirements.txt

2. Generate the Dataset

Run the data generation script to create a synthetic dataset of 300 scheme applicants:

python utils/generate_data.py

This will output data/fraud_dataset.csv.

3. Train the Model

Train the fraud detection model:

python utils/train_model.py

This will train the model and save it to models/fraud_model.pkl.

4. Configure Environment

To use the AI explanation feature, create a .env file from the example:

cp .env.example .env

Open .env and add your OpenAI API key.

5. Start the Backend API

Run the FastAPI application using Uvicorn:

uvicorn backend.main:app --reload

The API will be accessible at: http://127.0.0.1:8000.

6. Start the Frontend Dashboard (Optional)

Run the Streamlit UI to get a user-friendly dashboard:

streamlit run frontend/app.py

The dashboard will open automatically in your browser.

API Endpoints

  • GET / — Health check endpoint.
  • POST /predict — Used to check an applicant for fraud. Example payload:
    {
      "income": 25000,
      "family_size": 4,
      "location": "Delhi",
      "scheme_type": "PM_Kisan",
      "bank_account": "ACC999",
      "phone_number": "9998887776"
    }
  • POST /explain — Submits a prediction result to generate a human-readable AI explanation. Example payload:
    {
      "income": 95000,
      "family_size": 1,
      "location": "Delhi",
      "scheme_type": "PM_Kisan",
      "fraud": 1,
      "confidence": 87.5,
      "anomaly_score": -0.12,
      "graph_cluster_size": 8,
      "graph_connected_fraud_rate": 75.0
    }

About

SmartGov AI is an advanced AI-powered fraud detection system designed to enhance transparency and efficiency in government welfare schemes. It leverages machine learning, anomaly detection, and explainable AI to identify suspicious applications and prevent misuse of public funds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages