A complete end to end system for water consumption forecasting involving Data Preprocessing, Model Building using CNN-LSTM, and Model Deployment using Docker and Flask.
The repository contains the following Files and Folders
- Images: Various Images such as logo, docker deployment, results etc.
- PreProcessing_Notebook.ipynb: Notebook containing preprocessing codes of the data.
- Training_Notebook.ipynb: Notebook containing training codes for water consumption forecasting.
- Dockerfile: Docker File for Deployment.
- requirements.txt: Contains various packages and dependencies required for the project.
- config.yaml: Configuration file for changing variables and paths of the project.
- main.py: Contains script for training the model.
- app.py: Backend for web application deployment using flask.
- templates/index.html: Frontend for web application deployment using flask.
Due to privacy reason, the data cant be shared, but details and format of the data is shown below.
-
Data has water consumption details for 5 households: A, B, C, D, E.
-
Sample data format is shown below.
id,starttime,stoptime,water_consumption B,2020-12-21 17:49:09.000,2020-12-21 17:50:05.000,2.8 B,2020-12-22 20:08:54.000,2020-12-22 20:10:01.000,4.2 A,2020-11-20 06:18:14.000,2020-11-20 06:18:14.000,0.5 A,2020-11-04 23:31:43.000,2020-11-04 23:31:45.000,0.5 A,2020-09-21 10:08:48.000,2020-09-21 10:08:53.000,2.7 C,2020-09-02 23:06:45.000,2020-09-02 23:06:45.000,0.9 C,2020-12-04 06:07:23.000,2020-12-04 06:07:23.000,1.1 -
In data places where there is no consumption of water, data is not provided.
-
Data is present in txt file format in our case.
-
Open the Notebook
PreProcessing_Notebook.ipynbto follow all the preprocessing steps of the data. -
Open the Notebook
Training_Notebook.ipynbto follow all the training steps of the model.Alternatively to train the model.
-
Open command line cmd at the root of the repository.
-
Run the command
pip install -r requirements.txt -
Run the command
python main.py
-
NOTE: In order to make path, variables or any related change, please change the config.yaml file.
-
A
Dockerfileis provided which can be used for deployment. From thisDockerfilea docker image can be created and deployed in cloud, etc.-
To create a docker image, first download docker for your OS from the official docker website.
-
Then, open a command line cmd at the root of the repository, and run the command:
docker build -t water_consumption_image:v1 . -
Once the image is created, you can push the docker image to the docker hub after signing in, from where the image can be used.
-
To run the docker image, open a command line cmd at the root of the repository, and run the command:
docker run -p 5000:5000 water_consumption_image:v1 -
Open the link on your preffered browser:
http://127.0.0.1:5000/, or check the logs provided by Docker in command line, to find the link.
-
-
Also a seperate
templates/index.htmlandapp.pyis provided which can serve as frontend and backend for a web app based water demand prediction deployment system.To run the application, open a command line cmd at the root of the repository, and run the command:
flask run -
In the future all models can be stored on cloud for sending a
requestand getting aresponsefor demand prediction.
The whole project is developed with python version Python 3.7.7 and pip version pip 19.2.3.
In case of error, feel free to contact me over Linkedin at Adnan.