Skip to content

Akank0706/AI-Energy-Forecasting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Energy-Forecasting

Beginner-friendly Python project for hourly energy consumption forecasting using a neural network (MLPRegressor), with a Flask API, a Streamlit dashboard, and a clear modular layout.

Features

  • Load CSV time series, resample to hourly frequency, and handle missing values
  • Features: hour (0–23) and day of week (0–6, Monday=0)
  • Train / test split (time-based), MAE, RMSE,
  • Save the trained Pipeline (scaler + MLP) with joblib
  • Plots saved under images/
  • POST /predict API: JSON {"hour": int, "day": int} → predicted energy

Project layout

AI-Energy-Forecasting/
├── api/app.py              # Flask API
├── dashboard/app.py        # Streamlit UI
├── data/energy.csv         # Dataset (generate sample below)
├── images/                 # Figures from main.py
├── models/energy_model.pkl # Created after training
├── src/                    # Core library modules
├── main.py                 # Full training pipeline
├── requirements.txt
└── scripts/generate_sample_data.py

Quick start

1. Environment

python -m venv .venv
.venv\Scripts\activate          # Windows
# source .venv/bin/activate     # macOS / Linux
pip install -r requirements.txt

2. Sample data (optional)

python scripts/generate_sample_data.py

Replace data/energy.csv with your own file if you prefer. Expected columns:

  • timestamp — parseable datetimes
  • energy — numeric consumption

3. Train and export artifacts

python main.py

This writes:

  • models/energy_model.pkl
  • predictions.csv
  • metrics.txt
  • images/*.png

4. Flask API

From the project root:

python api/app.py

Example request:

curl -X POST http://127.0.0.1:5000/predict -H "Content-Type: application/json" -d "{\"hour\": 18, \"day\": 4}"

5. Streamlit dashboard

streamlit run dashboard/app.py

Development notes

  • Run API and Streamlit from the repository root so imports and paths resolve correctly.
  • If you change the model file, restart the Streamlit app (or clear cache from the menu) so the new model loads.

License

MIT (adjust as needed for your course or organization).

Author

Akanksha Andhale

About

AI-powered system to forecast energy consumption using machine learning, with an interactive Streamlit dashboard for real-time predictions and analytics.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages