Git Product home page Git Product logo

energy_forecasting's Introduction

Energy Consumption Forecasting

This project aims to forecast the energy consumption of the different regions of Denmark, allowing ML-driven decisions to allocate resources efficiently.

Table of Content

ML Lifecycle

The ML Lifecycle uses batch processing with an FTI(Feature-Training-Inference) methodoloy, allowing to decouple the different components of this pipeline, sticking to good MLOps practices. Also a monitoring step to calculate the error of the predictions on a hourly basis.

The data is served by two UIs or via REST APIs.

Infrastructure

Architecture

How to Run?

Credentials

To configure the credentials values there are two possible ways:

  1. Create .env files based on the .env.default values of the different folders and set values.
  • Folders to check
  • src/app-api
  • batch-prediction-pipeline
  • training-pipeline
  • feature-pipeline
  1. Set all necesary credentials as environment variables, a 'settings.py' file will automatically load the variables.
export FS_API_KEY=${value}
export FS_PROJECT_NAME=${value}  
export WANDB_API_KEY=${value}  
export WANDB_ENTITY=${value}  
export WANDB_PROJECT=${value}  
export AWS_ACCESS_KEY_ID=${value}  
export AWS_SECRET_ACCESS_KEY=${value}  
export AWS_BUCKET_NAME=${value}  

Build with Terraform

  1. Configure credentials (if were not already defined as env variables)
export AWS_ACCESS_KEY_ID=${value}  
export AWS_SECRET_ACCESS_KEY=${value}  
  1. Run the follwing command:
cd infrastructure/terraform
terraform plan
terraform apply -auto-approve

Configure with Ansible

  1. Upload your keypair
mkdir {WORKDIR}/infrastructure/ansible/keys                                             # Create key folder
mv {KEYPAIR_PATH}/TF_EnergyConsumption.pem {workdir}/infrastructure/ansible/keys        # Upload your key
  1. Configure API keys There is a default file with all the necessary APIs keys
cat {ANSIBLE_PATH}/inventories/dev/group_vars/secrets.default.yml >> secrets.test.yml    # Configure all the API keys in a new file    
ansible-vault encrypt {ANSIBLE_PATH}/inventories/dev/group_vars/secrets.enc.yml
  1. Configure ansible-vault password
{your_ansible_password} >> {ANSIBLE_PATH}/inventories/dev/group_vars/secrets-key
  1. Configure IP addresses This can be done after deploying your infrastructure, because public IP addresses for the servers are randomly assigned from a pool. Open the following file: {ANSIBLE_PATH}/inventories/dev/hosts.ini and replaced the IP addresses.

  2. Configurate servers. Once all previous steps are correctly done, configure the servers running the following command:

ansible-playbook system.yml

Configurations takes between 5-10 minutes

LOCAL DEBUGGING

[NOTE!] Make sure the configure all the credentials before

To debug the application locally, run the following commands:

docker-compose build src/airflow/
docker-compose up src/airflow/

docker-compose build src/deploy/
docker-compose up src/deploy

PROJECT STRUCTURE

The project main structure is as follows:

├── README.md                       
├── .github/workflows               
│   ├── CI/CD Pipelines             
├── infastructure                   
│   ├── ansible                     
│   │   ├── group_vars              
│   │   ├── playbooks               
│   │   └── hosts.ini               
│   ├── terraform                   
│   │   ├── modules
├── src               
│   ├── airflow                     
│   ├── app-api                     
│   ├── app-frontend                
│   ├── app-monitoring              
│   ├── batch-prediction-pipeline   
│   ├── deploy                      
│   ├── feature-pipeline            
│   ├── training-pipeline           

Main Stack

Frontend

  • Streamlit - The UI to visualize data metrics and predictions

Backend

  • FastAPI - The API to communicate with website application

MLOps

  • Airflow - Scheduling, managing and running the different pipelines
  • Hopsworks - The feature store used to versionize the data
  • Weights&Biases - Logging and saving models metrics and model registry

DevOps

User Interface

Two different webpages UI were built, the fisrt one for visualizing the forecasting data of the differents zones, while the other allows to compare the predicted data with the truth data collected each hour.

 

PREDICTION


MONITORING

energy_forecasting's People

Contributors

marianopareja avatar

Watchers

 avatar

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.