Tirth PatelAI Engineer
Back to All Projects
AI/MLFRONTEND DEMO

PMGSY Infrastructure Classification & GenAI Explanation Agent

End-to-end Machine Learning pipeline classifying rural road projects using Random Forest and natural language explanations with IBM Granite 4 on watsonx.ai.

Python 3.11Scikit-Learn (Random Forest)IBM Granite 4 SmallIBM watsonx.aiFlaskPandas & NumPyChart.js
Interactive Frontend EnvironmentLive Preview

Interactive Client-Side Demonstration • Features sample road infrastructure records and pre-trained classification demonstration.

The Problem Statement

What real-world challenge does this system address?

Government infrastructure datasets are dense, heterogeneous, and difficult for non-technical stakeholders to audit. Misallocating rural development schemes leads to funding delays and regulatory compliance failures.
The Engineering Solution

System Design & Approach

Combines an ensemble Random Forest classifier (300 estimators, 5-fold cross-validation, class balancing) with automated feature engineering and LLM natural-language summaries to provide transparent reasoning for each classification.
Key Capabilities:
  • 300-Tree Balanced Random Forest: Robust against heavy class imbalance across rural scheme records.
  • Comprehensive Feature Engineering: Automated handling of missing geographic values, numeric coercion, and cost-per-km ratio features.
  • GenAI Policy Explanations: Invokes IBM Granite 4 Small on watsonx.ai to output concise textual rationale for why a project aligns with PMGSY-I, II, III, or special packages.
  • Interactive Confusion Matrix & Metrics Dashboard: Visualizes precision, recall, and state-by-state classification distributions.
System Architecture Flow

System Architecture & Dataflow

Raw CSV (2,189 rows) -> Preprocessing & Feature Engineering -> 300-Tree Random Forest Classifier -> watsonx.ai Granite 4 LLM -> Flask Web Dashboard

Phase 01:Data Ingestion & Cleaning

Cleans state identifiers, handles NaNs, computes road length/cost ratios, and applies StandardScaler.

ETL & PreprocessingPandas & Custom Preprocessor
Phase 02:Model Inference

Predicts the scheme category across 5 target classes (PMGSY-I, II, III, RCPLWEA, PM-JANMAN).

Ensemble ClassifierScikit-Learn RandomForestClassifier
Phase 03:Explanation Synthesis

Synthesizes contextual rationale connecting feature attributes to federal scheme eligibility criteria.

Natural Language ReasoningIBM watsonx.ai (Granite 4 Small)
Phase 04:Visual Reporting

Renders class confidence distributions, confusion matrix heatmaps, and audit reports.

Dashboard PresentationFlask + Chart.js + HTML5
Technical Implementation

Stack Specification & Components

Language & Runtime

Python 3.11

Framework

Flask Backend with Scikit-learn Pipeline

Database / Storage

PMGSY_DATASET.csv (2,189 verified infrastructure records)

Deployment Target

Flask WSGI / Web Showcase

Key Libraries
scikit-learnpandasnumpyjoblibrequests
Interactive Demonstration Sandbox
Client-Side Simulation

PMGSY Random Forest & Granite 4 Explanation Demo

Evaluates road attributes across 32 state weights & generates synthetic rationale

watsonx.ai Granite 4 Demo
Random Forest Classification:PMGSY-III (Confidence: 94.6%)
IBM Granite 4 Natural Language Explanation:

“High cost-per-km ratio and interstate connectivity characteristics indicate consolidation under PMGSY-III guidelines. Evaluated across Madhya Pradesh rural infrastructure parameters.”

Architectural Rationale & Tradeoffs

Engineering Decisions

Key design choices, constraints, and solutions formulated during development

Random Forest with Class Balancing vs. Deep Neural Net

Decision:

Selected a 300-tree Random Forest with balanced class weights rather than an artificial neural network.

Engineering Rationale:

Tabular data with categorical state variables and skewed class distributions performs better and avoids overfitting on tabular datasets under 5,000 samples, while offering intrinsic feature importance rankings.

Dual-Layer Classification + Explanation Architecture

Decision:

Used classical ML for deterministic label prediction and an LLM strictly for explanation synthesis.

Engineering Rationale:

Ensures the core classification remains verifiable and statistically grounded while harnessing LLM fluency without risking hallucinations on numerical thresholds.