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.
- 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.
- 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.
-
Clone the repository:
git clone https://github.com/rashi-raturi/Energy-Consumption-Predictor.git cd Energy-Consumption-Predictor
-
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
-
To run both FastAPI and Streamlit on different ports:
-
Start FastAPI:
cd fastapi uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
Start Streamlit:
cd streamlit streamlit run app.py
Now, you should be able to access:
- FastAPI:
http://localhost:8000
- Streamlit:
http://localhost:8501
- 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 }
├── 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