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.
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.
- 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
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
- Framework: Streamlit (interactive web UI)
- Model: Amazon Chronos T5 (Hugging Face Hub)
- Backend: PyTorch
- Data: Pandas, NumPy
- Visualization: Matplotlib
- Python 3.8 or higher
- 4GB RAM minimum (8GB recommended for faster inference)
- ~2GB disk space (for model downloads)
-
Clone or download the repository
cd energy-forecast -
Create virtual environment (recommended)
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
streamlit run app.py
The app will open at
http://localhost:8501
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
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
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.
-
Select Model Size (sidebar)
- Choose between tiny, small, or base model
- Larger = better accuracy, slower inference
-
Set Historical Data Range (sidebar)
- 7-60 days of historical data
- More data = better pattern learning
-
View Results
- Historical consumption chart
- 24-hour forecast chart
- Detailed hourly predictions
- Summary statistics
-
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
-
Go to share.streamlit.io
- Sign in with GitHub
- Click "New app"
- Select repository and main file (
app.py) - Deploy
-
Share the live link
app.py- Main Streamlit applicationgenerate_data.py- Synthetic data generationrequirements.txt- Python dependenciesREADME.md- This file
- 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)
- 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
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
This prototype is for educational purposes.
Author: Created for AI Design Course Date: January 2025 Status: Working prototype