Inspiration

The project's inspiration came directly from the hackathon's "Short-term energy load forecasting" track, which highlighted buildings' critical role in global energy use and decarbonization. We were particularly motivated by the idea of creating scalable and adaptive AI solutions for managing energy across various commercial and residential properties. The concept of Time Series Foundation Models (TSFMs) deeply resonated, offering a vision for intelligent systems that learn generalizable patterns, reducing the need for unique models for every new building. Our goal was to build a dashboard that not only forecasts future energy needs but also proactively identifies anomalies, providing actionable insights to make buildings smarter and more sustainable.

What it does

This project delivers an AI-Powered Building Energy Forecasting & Anomaly Detection system designed for commercial and residential buildings. It provides a real-time, interactive dashboard that allows users to: Monitor Live Energy Data: View real-time energy consumption, solar generation, and temperature for selected buildings. Identify Anomalies: Detect unusual energy consumption patterns in real-time, indicating potential inefficiencies or issues. Access Short-Term Forecasts: See 24-hour energy consumption forecasts, powered by a generalized AI model. Select Different Buildings: Dynamically switch between various simulated residential and commercial buildings to view their specific data and predictions. The system showcases the TSFM concept by using a single, robust AI model to provide accurate forecasts and anomaly detection across different building types without requiring individual model retraining

How we built it

The project utilizes a modular, full-stack architecture:

  1. Data Simulation Layer (data-simulator/) A Python script (simulate_data.py) generates synthetic energy consumption, solar generation, and temperature data. It simulates data for multiple distinct building IDs, each with a building_type (e.g., 'Residential', 'Commercial') and a unique daily energy pattern. Intentional anomalies are injected into the consumption data to test the anomaly detection system. Data is continuously appended to energy_readings.csv.
  2. AI/ML & Backend API Layer (ai-models/ & backend/) AI Models (ai-models/train_model.py): Pre-processed multi-building data, extracting time-based features, environmental factors, and applying one-hot encoding to building_type. A single, generalized LSTM neural network was trained on this comprehensive dataset, acting as our TSFM for short-term load forecasting. An Isolation Forest model was trained on the aggregated consumption data for adaptive anomaly detection. Trained models (.keras, .pkl), MinMaxScaler, and model_features.pkl (containing exact feature order) were saved for consistent inference. Flask Backend API (backend/app.py): Loads all pre-trained AI models, the scaler, and the model_features list. Exposes RESTful endpoints for: Retrieving a list of available buildings. Fetching the latest energy reading and applying real-time anomaly detection for a specific building. Generating 24-hour energy consumption forecasts for a specified building using the TSFM. Handles dynamic data preprocessing to ensure model inputs match training requirements.
  3. Frontend Dashboard Layer (frontend/) A responsive web dashboard built with React.js. Fetches available buildings and data from the Flask API. Features a "Select Building" dropdown to dynamically view data for different simulated buildings. Uses Recharts for visualizing: Live energy consumption and solar generation. AI-powered 24-hour energy consumption forecasts. Provides clear UI for anomaly detection status. ## Challenges we ran into Building this integrated system came with several key challenges: Data Consistency & Feature Alignment: Ensuring that the complex feature engineering pipeline (including one-hot encoding for building_type) remained perfectly synchronized across the data simulator, model training, and backend API inference was a recurring hurdle. Mismatches in feature names, order, or data types led to errors. Persistent JSON Serialization Issue: A specific TypeError: Object of type bool is not JSON serializable in the Flask backend for the is_anomaly field was particularly challenging. Despite Flask's usual handling of Python booleans, the solution required explicitly converting True/False to "true"/"false" strings for reliable JSON serialization in the deployment environment. Dynamic TSFM Input Generation: Crafting the feature vector for future time steps in the forecasting loop (get_actual_forecast function) was intricate. It demanded dynamically constructing the input, including correct one-hot encoding for the selected building_type and other time-varying features, based on the model_features.pkl list to maintain the model's expected input format. Inter-Service Debugging: Diagnosing issues across the three separate components (simulator, backend, frontend) required careful isolation and step-by-step verification, especially when API calls failed due to data payload or connection issues. ## Accomplishments that we're proud of We're particularly proud of: End-to-End System Integration: Successfully building and integrating a full-stack application that seamlessly combines data simulation, AI/ML models, a robust API, and an interactive frontend. Implementing the TSFM Concept: Demonstrating how a single, generalized LSTM model can effectively forecast energy loads across multiple, distinct building types (residential and commercial) without per-building retraining, showcasing the power of foundational models in time-series analysis. Real-time Anomaly Detection: Developing a functional anomaly detection system that can identify unusual energy consumption patterns in real-time for any selected building. Dynamic Building Selection: Creating an intuitive user interface that allows dynamic switching between buildings, immediately updating all visualizations and predictions, proving the scalability of our approach. Overcoming Technical Hurdles: Successfully debugging persistent data serialization and feature consistency issues across the stack, demonstrating strong problem-solving capabilities.

What we learned

This project provided invaluable learning experiences: Deeper Understanding of Full-Stack AI: Solidified understanding of the entire pipeline, from data generation and feature engineering to model deployment and interactive visualization. Practical TSFM Application: Gained hands-on experience in how to conceptually build and apply a generalized time-series model that can adapt to new domains (buildings). Robust Feature Engineering: Learned to meticulously prepare data, including handling categorical features with one-hot encoding, and ensure feature consistency for ML models. Advanced Python & Flask API Development: Enhanced skills in building maintainable and scalable RESTful APIs. React State Management for Dynamic Data: Improved proficiency in managing application state for real-time data updates and user interactions. Systematic Debugging: Developed stronger debugging strategies for complex, multi-component applications.

What's next for AI-Powered Building Energy Forecasting & Anomaly Detection

Our vision for future development includes: Database Integration: Replacing the CSV with a time-series database (e.g., InfluxDB or PostgreSQL with TimescaleDB extension) for scalable and robust data storage. Real-time Data Streaming: Implementing a message broker (e.g., Apache Kafka) for high-throughput, real-time data ingestion from simulated (or actual) sensors. Advanced Model Architectures: Exploring Transformer networks or hybrid models to potentially enhance forecasting accuracy further. Actionable Recommendations: Developing a module to provide automated, actionable insights and recommendations based on forecasts and detected anomalies. User Authentication & Multi-Tenancy: Implementing secure user login and role-based access to manage multiple buildings. Cloud Deployment: Deploying the entire application stack to a cloud platform for real-world accessibility and scalability.

Built With

  • axios-(http-client)
  • development
  • environment:
  • github.
  • javascript-frameworks/libraries-(backend-&-ai):-flask-(python-web-framework)
  • joblib-(model-serialization).-frameworks/libraries-(frontend):-react.js-(javascript-ui-library)
  • languages:-python-3.x
  • numpy-(numerical-computing)
  • pandas-(data-manipulation)
  • python
  • recharts-(charting-library).-styling:-plain-css.-version-control:-git
  • scikit-learn-(machine-learning)
  • tensorflow/keras-(deep-learning)
  • virtual
  • vite-(build-tool)
Share this project:

Updates

Submission history