Skip to content

DataDollars/BESCOME

Repository files navigation

GRID-IQ Prototype

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.

Features

  • 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.

Setup & Installation

  1. Ensure you have Python 3.11+ installed.
  2. Create and activate a virtual environment:
    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt

Running the Prototype Locally

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

Deploying to Streamlit Community Cloud

Since the architecture is fully self-contained, deploying to the cloud is seamless:

  1. Commit and push this entire directory to a public GitHub repository.
  2. Go to share.streamlit.io.
  3. Connect your GitHub account and select your newly created repository.
  4. Set the Main file path to app.py and click Deploy.
  5. Your GRID-IQ Command Center is now live!

Default Credentials

  • 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

Project Structure

  • 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 (plain Meter_IDs).
  • ingestion_pipeline.py: Securely ingests raw data, hashes IDs to Meter_ID_Hash, drops raw data, and builds the rbac.db mapping.
  • runner.py: Orchestrates the multi-step pipeline (Generation -> Ingestion -> API/UI start).
  • requirements.txt: Python dependencies.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages