GitHunt
IS

ishubhgupta/Energy-Insight

Advanced Predictive Analytics for Building Efficiency

EnergyInsight v2.0 - Modular Streamlit Application

Overview

EnergyInsight is a sophisticated, modular Streamlit application for predicting building energy loads using machine learning. The application has been completely rebuilt with a clean, maintainable architecture.

Tagline: "You Make, We Save"

Project Structure

Energy-Insight/
├── streamlit_app.py              # Main application entry point
├── requirements.txt              # Python dependencies
├── .env                          # Environment variables (create this)
│
├── config/                       # Configuration module
│   ├── __init__.py
│   └── config.py                 # All constants and settings
│
├── src/                          # Source code
│   ├── __init__.py
│   │
│   ├── models/                   # ML model handlers
│   │   ├── __init__.py
│   │   └── model_handler.py      # Model loading and predictions
│   │
│   ├── utils/                    # Utility functions
│   │   ├── __init__.py
│   │   ├── utils.py              # Weather, calculations, helpers
│   │   └── ai_helper.py          # Gemini AI integration
│   │
│   └── pages/                    # Streamlit pages
│       ├── __init__.py
│       ├── heating_cooling.py    # Heating/cooling load page
│       └── appliance_energy.py   # Appliance energy page
│
├── Dump/main/                    # Data and models
│   ├── ENB2012_data.csv          # Building energy dataset
│   ├── training.csv              # Appliance training data
│   ├── testing.csv               # Appliance test data
│   └── *.joblib                  # Pre-trained ML models
│
├── heatLoad.joblib               # Heating model (root)
├── coolLoad.joblib               # Cooling model (root)
└── appliance.joblib              # Appliance model (root)

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Set Up Environment Variables

Create a .env file in the root directory:

# Google Gemini AI API Key (for AI recommendations)
GOOGLE_API_KEY=your_google_api_key_here

# OpenWeatherMap API Key (for weather data)
OPENWEATHER_API_KEY=your_openweather_api_key_here

Note: The app will work without these keys, but AI recommendations and weather features will be limited.

3. Run the Application

streamlit run streamlit_app.py

The application will open in your default browser at http://localhost:8501

Features

Heating & Cooling Load Prediction

  • Predict energy loads based on building characteristics
  • Real-time weather integration
  • Seasonal detection and optimization
  • AI-powered HVAC recommendations
  • Room-by-room condition tracking (optional)
  • Efficiency ratings and analysis

AI-Powered Recommendations

  • Context-aware suggestions via Google Gemini
  • Personalized optimization strategies
  • HVAC efficiency tips
  • Behavioral recommendations

🔧 Module Details

Configuration (config/config.py)

  • API keys and endpoints
  • Model paths and data locations
  • Feature definitions
  • CModule Details

Configuration (config/config.py

Model Handler (src/models/model_handler.py)

  • Loads pre-trained ML models
  • Handles predictions for all models
  • Can retrain models if needed
  • Centralized model management
  • Caching for performance

Utilities (src/utils/utils.py)

  • Weather API integration
  • Dew point calculations
  • Season detection
  • Building feature calculations
  • Validation functions
  • Helper utilities

AI Helper (src/utils/ai_helper.py)

  • Google Gemini AI integration
  • Context-aware prompt generation
  • Specialized recommendations
  • Error handling
  • Caching for efficiency

Pages

  • Heating/Cooling (src/pages/heating_cooling.py): Building energy analysis with optional room conditions

Machine Learning Models

Heating & Cooling Load Models

  • Algorithm: LightGBM Regressor
  • Dataset: ENB2012_data.csv (768 samples)
  • Features: 10 (8 input + 2 calculated)
  • Outputs: Heating Load (kWh), Cooling Load (kWh)
  • Models: heatLoad.joblib, coolLoad.joblib

Key Improvements

Architecture

  • Modular Design: Clean separation of concerns
  • Reusable Components: DRY principles throughout
  • Centralized Config: Easy to maintain and modify
  • Type Hints: Better code documentation
  • Error Handling: Robust error management

Code Quality

  • Documentation: Comprehensive docstrings
  • Organization: Logical file structure
  • Maintainability: Easy to extend and modify
  • Performance: Caching and optimization
  • Scalability: Ready for future features

User Experience

  • Intuitive Navigation: Clear page structure
  • Visual Feedback: Progress indicators
  • Responsive Design: Multi-column layouts
  • Help Text: Tooltips and descriptions
  • Error Messages: Clear user guidance

API Keys

Google Gemini AI (Optional)

Get your key from: https://makersuite.google.com/app/apikey

  • Used for AI-powered recommendations
  • App works without it (recommendations disabled)

OpenWeatherMap (Optional)

Get your key from: https://openweathermap.org/api

  • Used for real-time weather data
  • Default key provided (limited usage)

🛠️ Development

Adding New Features

  1. New Page:

    • Create file in src/pages/
    • Import in streamlit_app.py
    • Add navigation option
  2. New Model:

    • Add model path to config/config.py
    • Add methods to ModelHandler class
    • Create prediction page
  3. New Utility:

    • Add function to src/utils/utils.py
    • Import where needed
    • Update __init__.py
      config/config.py
    • Add methods to ModelHandler class
    • Create prediction page
  4. New Utility:

    • Add function to src/utils/utils.py
  • Use descriptive variable names
    init.py

Model Training

The models are pre-trained and included as .joblib files. To retrain:

from src.models import get_model_handler

model_handler = get_model_handler()

# Retrain heating/cooling models
model_handler.train_heating_cooling_models(force_retrain=True)

Troubleshooting

Models Not Found

  • Ensure .joblib files are in the models/ directory
  • Check config/config.py for correct paths
  • Models will auto-train if data files exist

Import Errors

  • Verify Python path includes project root
  • Check all __init__.py files exist
  • Install all requirements

API Erro__init__.py files exist

  • Install all requirements

API Errors

  • Check API keys in .env

📝 License

This project is for educational and research purposes.

🤝 Contributing

  1. Fork the repository
  2. ate a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

📞 Support

For issues, questions, or suggestions:

  • Ck existing documentation
  • Review code comments
  • Examine example usage
  • Test with sample data

🎓 References

Datasets

  • B2012:* Energy Analysis of Buildings Dataset
  • Appliance Energy: Household Appliance Energy Prediction Dataset

Technologies

  • scikit-learn: Machine learning library
  • LightGBM: Gradient boosting framework
  • scikit-learn: Machine learning library
  • Google Gemini: AI recommendations
  • OpenWeatherMap: Weather data API

Version: 2.1.0
Last Updated: January 2026
Status: Production Ready

ishubhgupta/Energy-Insight | GitHunt