A newer version of the Gradio SDK is available: 6.22.0
title: Complaint Auto-Routing System
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 5.44.0
app_file: app.py
pinned: false
Complaint Auto-Routing System
An end-to-end machine learning system that processes citizen complaints submitted in text, audio, or video format. It is designed to run fully offline without external APIs.
It automatically performs the following tasks:
- Officer Routing: Assigns the complaint to the most suitable officer from an internal list using an SVM.
- Priority Prediction: Classifies the priority as High, Medium, or Low using a Random Forest.
- ETA Prediction: Estimates resolution time in days using a Gradient Boosting Regressor.
- Similarity Search: Retrieves similar past complaints using cosine similarity over text embeddings.
Project Screenshots
Text Complaint
Audio Complaint
Video Complaint
Project Structure
complaint-routing-system/
βββ data/
β βββ generate_data.py # Synthetic complaint generator
β βββ synthetic_complaints.csv # 800 labelled complaints (auto-generated)
βββ models/
β βββ train.py # End-to-end training pipeline
β βββ saved/ # Trained model artifacts
βββ inference/
β βββ embedding_engine.py # TF-IDF+SVD or sentence-transformers
β βββ vector_store.py # NumPy cosine search
β βββ engine.py # Core inference engine (load + predict)
βββ audio_video/
β βββ transcriber.py # Whisper-based offline ASR (audio + video)
βββ app/
β βββ cli.py # Command-line interface
β βββ web_app.py # Gradio web UI
βββ evaluation/
β βββ evaluate.py # Full evaluation suite
βββ requirements.txt
βββ README.md
Quick Start
1. Install dependencies
# Core requirements
pip install scikit-learn numpy pandas scipy joblib
# Embedding model
pip install sentence-transformers
# Web UI
pip install gradio
# Audio/Video transcription (requires ffmpeg installed on your system)
pip install openai-whisper
2. Generate training data and train models
python data/generate_data.py
python models/train.py
3. Run inference
# Interactive CLI
python app/cli.py
# Direct text
python app/cli.py --text "Pothole on MG Road near hospital causing accidents. URGENT!"
# Web UI
python app/web_app.py
4. Run evaluation
python evaluation/evaluate.py
Architecture
The system takes in text, audio, or video. If audio or video is provided, it uses the local Whisper model to transcribe the speech offline.
The text is then passed to an embedding engine (using sentence-transformers). The resulting vector is passed to three separate scikit-learn models:
- Support Vector Machine (Officer Routing)
- Random Forest (Priority)
- Gradient Boosting Regressor (ETA)
The vector is also compared against a local NumPy store of historical complaints using cosine similarity to fetch the most relevant past issues.
Evaluation Results (5-fold Cross-Validation)
Officer Routing (SVM)
| Metric | Value |
|---|---|
| CV Accuracy | 1.000 Β± 0.000 |
| CV F1-macro | 1.000 Β± 0.000 |
Note: The synthetic data has very clear departmental boundaries (e.g., "pothole" maps strictly to roads). In a real-world scenario, accuracy would be closer to 85-90%.
Priority Prediction (Random Forest)
| Metric | Value |
|---|---|
| CV Accuracy | 0.578 Β± 0.014 |
| CV F1-macro | 0.566 Β± 0.020 |
ETA Prediction (Gradient Boosting)
| Metric | Value |
|---|---|
| CV MAE | 5.25 days |
| CV RMSE | 7.62 days |
Replacing Synthetic Data with Real Data
- Prepare a CSV with columns:
text,officer_id,priority,eta_days - Replace
data/synthetic_complaints.csv - Run
python models/train.py
The pipeline will automatically retrain all models on the new data and overwrite the old artifacts in models/saved.