A Python package to deploy FastAPI capable to optimize the water purification dosing process of the chemical "xy". The structure contains a SQLite3 database that collect measurements from sensors A and B with the information cleaned. Also, it has integrated regression model to train and predict de chemical dosing.
- If the user wants to isolate dependencies, he can install a virtual environment as follows:
python -m venv GreenWater source GreenWater/bin/activate # En Windows: GreenWater\Scripts\activate
- Install dependencies with a conda environment:
conda env create --name GreenWater --file environment.yml
- If the user prefers use requirements:
pip install -r requirements.txt
- To install the package GreenWater with setup file:
pip install -e .
Contains the file data.csv with the raw data.
Contains the sqlite predictions.db with RegressionModel results ordered by timestamp execution. in the following image you can see its structure using the Dbeaver desktop interface.
This is the project package with which the api executes its functionalities. It is governed by the Utils() class that stores the different project directories. The methods inside the class are:
- data_processing : To perform data processing.
- train_model : To train and save model, updating it with .pkl file.
- prediction_and_write_database : To determine prediction of the chemical and save the results in a sqlite3 database.
Is the folder that contains the train results, updating it according to the date of the last training session.
To start the API service, execute the following command:
bash uvicorn api:app --reload
The terminal will display the IP to which the service is pointing. If you using the extension /docs, we can see the main menu:
- /upload : Insert csv from data folder.
- /train-model : Updating training. In the next images, you can see how the .pkl file was updated in the source code when the process was executed in API.
- /train-model : A box is available for entering new sensor B measurements with which to generate predictions. As a result, a json is generated corresponding to the new instance that is added to the database.