Giter Site home page Giter Site logo

iamirmasoud / energy_consumption_prediction Goto Github PK

View Code? Open in Web Editor NEW
30.0 3.0 8.0 23.53 MB

Energy consumption prediction using LSTM/GRU networks in PyTorch

Jupyter Notebook 100.00%
energy-consumption gru lstm prediction python pytorch time-series deep-learning deep-neural-networks recurrent-neural-networks

energy_consumption_prediction's Introduction

Energy consumption prediction using LSTM/GRU networks in PyTorch

Project Overview

An hourly energy consumption prediction service for PJM Interconnection LLC Energy Consumption dataset based on GRU/LSTM networks using PyTorch framework.

In this project, I will use GRU and LSTM models for a time series prediction task. The goal is to create a model that can accurately predict energy usage in the next hour given historical consumption data provided by PJM Interconnection LLC Energy Consumption Dataset. I will be using both the GRU and LSTM model to train on a set of historical data and evaluate both models on an unseen test set. To do so, I'll start with feature selection, data-preprocessing, followed by defining, training, and eventually evaluating the models. I will use the PyTorch library to implement both types of models along with other common Python libraries used in data analytics. Finally, I will compare the performance of the GRU model against an LSTM model as well.


Preparing the environment

Note: I have tested this project on Linux. It can surely be run on Windows and Mac with some little changes.

Before you can experiment with the code, you'll have to make sure that you have all the libraries and dependencies required to support this project. You will mainly need Python 3, PyTorch and its torchvision, OpenCV, Matplotlib, and tqdm.

  1. Clone the repository, and navigate to the downloaded folder.
git clone https://github.com/iamirmasoud/energy-consumption-prediction .git
cd energy-consumption-prediction 
  1. Create (and activate) a new environment, named energy_env with Python 3.8. If prompted to proceed with the install (Proceed [y]/n) type y.

    conda create -n energy_env python=3.8
    source activate energy_env

    At this point your command line should look something like: (energy_env) <User>:energy-consumption-prediction <user>$. The (energy_env) indicates that your environment has been activated, and you can proceed with further package installations.

  2. Before you can experiment with the code, you'll have to make sure that you have all the libraries and dependencies required to support this project. You will mainly need Python3.8+, PyTorch and its torchvision, and Matplotlib. You can install dependencies using:

pip install -r requirements.txt
  1. Navigate back to the repo. (Also, your source environment should still be activated at this point.)
cd energy-consumption-prediction 
  1. Open the directory of notebooks, using the below command. You'll see all the project files appear in your local environment; open the first notebook and follow the instructions.
jupyter notebook
  1. Once you open any of the project notebooks, make sure you are in the correct energy_env environment by clicking Kernel > Change Kernel > energy_env.

Data

The dataset that we will be using is the PJM Interconnection LLC Energy Consumption Dataset provided by Kaggle. The dataset contains power consumption data across different regions around the United States recorded on an hourly basis.

Please download data and put it under the data subdirectory.

Use the pre-trained model

You can use my pre-trained models for your own experimentation. I put them in the models directory.

Results

While the GRU model may have made smaller errors and edged the LSTM model slightly in terms of sMAPE (Symmetric Mean Absolute Percentage Error), the difference is insignificant and thus inconclusive. There have been many other tests conducted by others comparing both these models but there has largely been no clear winner as to which is the better architecture overall.

Here are samples of energy consumption prediction results on test set for four different regions: alt text

It looks like the models are largely successful in predicting the trends of energy consumption. While they may still get some changes wrong, such as delays in predicting a drop in consumption, the predictions follow very closely to the actual line on the test set. This is due to the nature of energy consumption data and the fact that there are patterns and cyclical changes that the model can account for. Tougher time-series prediction problems such as stock price prediction or sales volume prediction may have data that is largely random or doesn’t have predictable patterns, and in such cases, the accuracy will definitely be lower.

energy_consumption_prediction's People

Contributors

iamirmasoud avatar

Stargazers

Luís Morgado avatar  avatar  avatar  avatar miracle avatar  avatar GasserAbdo avatar  avatar  avatar  avatar Pradeep avatar  avatar Haoran Zhang avatar  avatar Atharva Dastane avatar WeiboDev avatar yapeng avatar Jhon Lopez avatar Pedro Luis Dionísio Fraga avatar Dennis Irorere avatar  avatar  avatar Georg Walther avatar Gang Jiang avatar M.Ozkan Ceylan avatar Bahauddin Habibullah avatar Vikram avatar Vivek V Kini avatar  avatar  avatar

Watchers

Christos PANAGIOTOU avatar  avatar Kostas Georgiou avatar

energy_consumption_prediction's Issues

Biblioteca NUMPY

Bom dia, primeiramente parabéns pelo excelente conteúdo deste repositório, em seguida eu estou com problemas na biblioteca NUMPY, aparentemente a versão solicitada no arquivo "requeriments.txt" é a versão 1.23.3, porém ela não é encontrada pelo pip da versão que uso (10.0.1).
O erro é o seguinte: Could not find a version that satisfies the requirement numpy==1.23.3 (from -r requirements.txt (line 4)) (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6)
No matching distribution found for numpy==1.23.3 (from -r requirements.txt (line 4))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.