Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ AI-Powered Energy Consumption Forecasting System

Python Flask Scikit-learn Streamlit Status

Predict • Analyze • Save Energy • Reduce Carbon Emissions


📌 Overview

An AI system that predicts electricity consumption in real time using Machine Learning. It calculates energy wastage, detects peak hours, and fires smart alerts — supporting smart cities, power companies, and green energy goals.


❓ Problem Statement

  • Power grids fail to balance supply and demand → blackouts
  • Buildings use energy inefficiently → wastage and high bills
  • No forecasting = overuse of fossil fuels → carbon emissions
  • Manual monitoring is slow and error prone → delayed response

🏢 Companies Using Similar AI Systems

Google • Microsoft • Tesla • Siemens • Schneider Electric • TCS • Infosys • Wipro • Tata Power • Accenture


🛠️ Tech Stack

Tool Purpose
Python 3.11 Core language
Pandas & NumPy Data processing
Scikit-learn MLP Neural Network
Matplotlib & Seaborn Visualization
Flask REST API
Streamlit Interactive dashboard
Joblib Model saving

📊 Dataset

  • Source: Kaggle — Hourly Energy Consumption by Rob Mulla
  • Size: 145,000+ hourly records (16+ years of real data)
  • Unit: Megawatts (MW)
  • Link: Kaggle Dataset

🏗️ Architecture

Raw Data → Cleaning → Feature Engineering → Model Training → Forecasting → API → Dashboard

📁 Folder Structure

AI-Energy-Forecasting/
│
├── 📁 data/
│   ├── energy.csv                    ← original raw dataset
│   ├── energy_clean.csv              ← sorted and cleaned
│   └── energy_featured.csv           ← 8 ML features added
│
├── 📁 notebooks/
│   ├── 01_data_exploration.ipynb     ← EDA and visualization
│   ├── 02_feature_engineering.ipynb  ← feature extraction
│   ├── 03_model_training.ipynb       ← model training
│   └── 04_forecasting.ipynb          ← 7 day forecast
│
├── 📁 models/
│   ├── energy_forecast_model.pkl     ← trained MLP model
│   └── scaler.pkl                    ← fitted scaler
│
├── 📁 outputs/
│   ├── predictions.csv               ← 7 day forecast
│   └── evaluation_metrics.txt        ← MAE, RMSE, R²
│
├── 📁 images/                        ← all generated graphs
├── 📁 src/                           ← Python modules
├── 📁 docs/                          ← documentation
│
├── app.py                            ← Flask REST API
├── streamlit_app.py                  ← Streamlit dashboard
├── main.py                           ← main pipeline
├── run_dashboard.bat                 ← one click launcher
├── requirements.txt                  ← dependencies
└── .gitignore

⚙️ Installation

# Clone the repository
git clone https://github.com/YOUR_USERNAME/AI-Energy-Forecasting.git
cd AI-Energy-Forecasting

# Create virtual environment
py -3.11 -m venv venv
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

▶️ Usage

# Run main pipeline
python main.py

# Start dashboard
streamlit run streamlit_app.py

# Start Flask API
python app.py

📈 Model Results

Metric Value
MAE YOUR_MAE MW
RMSE YOUR_RMSE MW
R² Score YOUR_R2
Training Size 116,158 records
Testing Size 29,040 records
Features Used 8 features
Forecast Range 7 days ahead

🧠 How The AI Predicts

The model uses 8 inputs:

Time features: hour • day of week • month • quarter • is weekend

Lag features: energy 1 hour ago • 24 hours ago • 1 week ago

Everything is compared against the dataset average baseline of 32,080 MW to calculate wastage and trigger alerts.


💡 Dashboard Features

  • ⚡ Real time energy prediction
  • 💡 Wastage calculation vs historical average
  • 🔴 Peak / Normal / Off-Peak hour detection
  • ⚠️ Smart alerts for high consumption
  • 📈 Interactive charts — hourly, daily, monthly
  • 📂 Raw dataset explorer with filters
  • 🎯 Live model performance metrics

📸 Screenshots

Energy Trend

Energy Trend

Average Energy by Hour

Hourly

Average Energy by Day

Daily

Actual vs Predicted

Actual vs Predicted


📚 What I Learned

  • Real world time series data processing
  • Feature engineering and lag features
  • MLP Neural Network for regression
  • Model evaluation — MAE, RMSE, R²
  • REST API development with Flask
  • Interactive dashboard with Streamlit
  • End to end ML project development

🚀 Future Improvements

  • Use LSTM deep learning for better accuracy
  • Add weather data as additional feature
  • Deploy on AWS or Heroku
  • Add real time data streaming
  • Build mobile app version
  • Add anomaly detection system

👨‍💻 Author

Name Sonia Thakur
Email soniathakursonia068@gmail.com
LinkedIn https://www.linkedin.com/in/sonia-thakur-6ab93b349/
GitHub https://github.com/Sonia068

🎥 Demo Video

Watch Demo

👉 Click here to watch the full demo


⚡ Built with Python • Scikit-learn • Flask • Streamlit

Supporting Smart Cities • Green Energy • Net Zero Goals

About

⚡ AI-Powered Energy Consumption Forecasting System | Predicts electricity usage using MLP Neural Network | Real-time Streamlit Dashboard | Flask REST API | Supports Smart Cities & Green Energy Goals

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages