Skip to content

julidelgado/Energy-forecast-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Energy Consumption Forecaster

A machine learning prototype that predicts electricity consumption for the next 24 hours using Amazon Chronos, a state-of-the-art foundation model trained on over 1 million time-series datasets.

Overview

This application demonstrates the practical application of modern foundation models for real-world time-series forecasting. It simulates realistic hourly electricity consumption patterns and generates accurate 24-hour predictions.

Key Features

  • AI Model: Amazon Chronos T5 (tiny/small/base variants available)
  • Prediction Horizon: 24 hours ahead
  • Data: Simulated electricity consumption with realistic daily and weekly seasonality
  • Interface: Interactive Streamlit web application
  • Visualization: Real-time consumption charts and forecast tables

Use Case

Energy consumption forecasting is critical for:

  • Building Management: Optimize HVAC and lighting schedules
  • Grid Operations: Predict demand and balance supply
  • Cost Optimization: Plan usage during off-peak hours
  • Sustainability: Identify energy waste patterns

Technical Stack

  • Framework: Streamlit (interactive web UI)
  • Model: Amazon Chronos T5 (Hugging Face Hub)
  • Backend: PyTorch
  • Data: Pandas, NumPy
  • Visualization: Matplotlib

Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • 4GB RAM minimum (8GB recommended for faster inference)
  • ~2GB disk space (for model downloads)

Steps

  1. Clone or download the repository

    cd energy-forecast
  2. Create virtual environment (recommended)

    python -m venv venv
    
    # On Windows:
    venv\Scripts\activate
    
    # On macOS/Linux:
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Run the application

    streamlit run app.py

    The app will open at http://localhost:8501

How It Works

Data Flow

1. Generate simulated consumption data (30 days of hourly data)
2. Load Amazon Chronos model from Hugging Face
3. Feed historical data to the model
4. Model generates 24-hour forecast
5. Display results in interactive chart

Simulated Data

The synthetic dataset includes:

  • Daily Pattern: Peak consumption 9 AM - 6 PM (~50-90 kWh)
  • Night Base Load: Lower consumption overnight (~10-20 kWh)
  • Weekly Pattern: Slightly lower consumption on weekends
  • Random Noise: ±3 kWh realistic variations

Example:

- Weekday 2 PM: ~80 kWh
- Weekday 2 AM: ~12 kWh
- Weekend: ~10% lower than weekdays

Model Selection

Three model sizes available:

Model Parameters Speed Accuracy RAM
Tiny 8.4M Fastest Good <1GB
Small 46M Fast Better 1-2GB
Base 200M Slow Best 3-4GB

Recommendation: Start with "tiny" or "small" for faster results.

Usage

  1. Select Model Size (sidebar)

    • Choose between tiny, small, or base model
    • Larger = better accuracy, slower inference
  2. Set Historical Data Range (sidebar)

    • 7-60 days of historical data
    • More data = better pattern learning
  3. View Results

    • Historical consumption chart
    • 24-hour forecast chart
    • Detailed hourly predictions
    • Summary statistics

Deployment

Deploy to Streamlit Cloud (Free)

  1. Push code to GitHub:

    git init
    git add .
    git commit -m "Initial energy forecast prototype"
    git remote add origin <your-github-repo>
    git push -u origin main
  2. Go to share.streamlit.io

    • Sign in with GitHub
    • Click "New app"
    • Select repository and main file (app.py)
    • Deploy
  3. Share the live link

Files

  • app.py - Main Streamlit application
  • generate_data.py - Synthetic data generation
  • requirements.txt - Python dependencies
  • README.md - This file

Known Limitations & Future Improvements

Current Limitations

  • Uses simulated data (not real-world consumption)
  • Model inference can be slow on first run (downloads ~1GB model)
  • 24-hour forecast only (could extend to 7-14 days)

Possible Enhancements

  • Load real electricity data (CSV upload)
  • Add external variables (weather, holidays)
  • Ensemble multiple models
  • Confidence intervals for predictions
  • Historical accuracy metrics
  • User authentication for multi-tenant setup

About Amazon Chronos

Chronos is a foundation model trained by Amazon on diverse time-series data:

  • Training Data: 1 million+ different time-series
  • Capabilities: Univariate forecasting, handles various frequencies
  • Architecture: T5-based transformer model
  • Source: Hugging Face Hub

References

License

This prototype is for educational purposes.


Author: Created for AI Design Course Date: January 2025 Status: Working prototype

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages