Skip to content

A machine learning model using Linear Regression to predict energy consumption based on Square Footage, Occupants, Appliances, Temperature, Day of the Week, and Building Type. Achieved an R² score of 99.9999%. Built with Python, Pandas, Scikit-Learn, and Streamlit for visualization.

Notifications You must be signed in to change notification settings

rashi-raturi/Energy-Consumption-Predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Energy Consumption Predictor

This project uses a machine learning model to predict energy consumption based on various factors and displays the predictions in a visually interactive way using Streamlit and FastAPI. The backend uses FastAPI for API endpoints and Streamlit for the interactive dashboard. The prediction model helps in forecasting energy consumption based on the following features:

  • Square Footage
  • Number of Occupants
  • Appliances Used
  • Average Temperature
  • Day of the Week
  • Building Type (Industrial/Residential/Commercial)

The dataset can be download from the data folder.

Technologies Used

  • FastAPI: For the API endpoints and serving the machine learning model.
  • Streamlit: For building the interactive user interface and visualizations.
  • Plotly: For interactive charts like gauge charts and bar charts.

Features

  • Energy Consumption Prediction: Based on user inputs, predict energy consumption.
  • Visualization: A gauge chart to display the predicted energy consumption with color-coded levels.
  • Comparison: A bar chart comparing predicted energy consumption with the average consumption from the dataset.

Getting Started

Installation

  1. Clone the repository:

    git clone https://github.com/rashi-raturi/Energy-Consumption-Predictor.git
    cd Energy-Consumption-Predictor
  2. Install the required dependencies for both FastAPI and Streamlit:

    • For FastAPI:

      cd fastapi
      pip install -r requirements.txt
    • For Streamlit:

      cd streamlit
      pip install -r requirements.txt

Running Locally

To run both FastAPI and Streamlit on different ports:

  1. Start FastAPI:

    cd fastapi
    uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
  2. Start Streamlit:

    cd streamlit
    streamlit run app.py

Now, you should be able to access:

  • FastAPI: http://localhost:8000
  • Streamlit: http://localhost:8501

API Endpoints

/predict/ [POST]

  • Description: Accepts input data to predict energy consumption.
  • Request Body:
    {
        "Square_Footage": 2000,
        "Number_of_Occupants": 3,
        "Appliances_Used": 10,
        "Average_Temperature": 22,
        "Day_of_Week": 0,
        "Building_Type_Industrial": 0,
        "Building_Type_Residential": 1
    }
  • Response:
    {
        "predicted_energy": 4500
    }

Project Structure

├── Energy Consumption Predictor
├── app
|── init.py
|── main.py
|── model.pkl
├── data
├── train_energy_data.csv
├── test_energy_data.csv
├── utils
├── data_dicts.py
├── model_utils.py
├── views
├── charts.py
├── home.py
├── sidebar.py
├── model
├── eda.ipynb
├── README.md
├── requirements.txt

About

A machine learning model using Linear Regression to predict energy consumption based on Square Footage, Occupants, Appliances, Temperature, Day of the Week, and Building Type. Achieved an R² score of 99.9999%. Built with Python, Pandas, Scikit-Learn, and Streamlit for visualization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published