GRID-IQ is a Python-based decision-support prototype built for smart meter analytics, focusing on demand forecasting, anomaly detection, and Role-Based Access Control (RBAC) with strict local-inference privacy guardrails.
- Demand Forecasting: XGBoost regression models predict 24-hour grid demand based on historical interval data.
- Anomaly Detection: An Isolation Forest ensemble detects consumption drops or potential tampering.
- Explainable AI (XAI): SHAP values are calculated for every anomaly to generate an "Evidence Card" explaining exactly why a meter was flagged.
- RBAC & Authentication: Secure local SQLite database (
rbac.db) stores hashed passwords.- Admin: Can decode all pseudonymized Meter IDs.
- Field Officer: Can only decode Meter IDs explicitly assigned to them.
- Public/User: Can view the dashboard but cannot decode or take actions.
- Exportable Evidence Packages: Authorized users can download TXT reports of flagged anomalies for legal/audit purposes.
- Audit Logging: Every alert and user action (like "Assign Inspector") is securely logged to
system_audit.log.
- Ensure you have Python 3.11+ installed.
- Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
This prototype is now fully monolithic and does not require a separate backend server. If the datasets do not exist, they will be automatically generated upon launch.
To run the Streamlit dashboard locally:
streamlit run app.py- Streamlit Dashboard:
http://localhost:8501
Since the architecture is fully self-contained, deploying to the cloud is seamless:
- Commit and push this entire directory to a public GitHub repository.
- Go to share.streamlit.io.
- Connect your GitHub account and select your newly created repository.
- Set the Main file path to
app.pyand click Deploy. - Your GRID-IQ Command Center is now live!
- Admin: Username:
admin| Password:admin123 - Field Officer 1: Username:
officer_1| Password:pass1 - Field Officer 2: Username:
officer_2| Password:pass2 - Field Officer 3: Username:
officer_3| Password:pass3
app.py: The Streamlit dashboard UI.backend.py: The Flask API serving models and data.ml_engine.py: The core machine learning engine (XGBoost, Isolation Forest, SHAP).data_generator.py: Generates synthetic 15-min interval raw data simulating a BESCOM network export (plainMeter_IDs).ingestion_pipeline.py: Securely ingests raw data, hashes IDs toMeter_ID_Hash, drops raw data, and builds therbac.dbmapping.runner.py: Orchestrates the multi-step pipeline (Generation -> Ingestion -> API/UI start).requirements.txt: Python dependencies.