The ZDMP project is a European project created by a consortium of 40 entities, whose main objective is to provide a reference digital platform for the achievement of the "zero defects" objective, with which it is intended to support quality improvement both both in processes and in products. Manufacturing high-quality products at low cost is the best way for Europe to maintain leadership in the manufacturing industry and remain competitive in a global marketplace. This industry is in the midst of a digital transformation process, due to the proliferation and increase of new technological solutions, which are incorporated into the production chain to make it more efficient (Smart Factories and industry 4.0).
This is a project that aims to provide a reference digital platform for the achievement of the "zero defects" objective, with which it is intended to support quality improvement both both in processes and in products. All of this content comes from iti.es ZDMP Datathon and Hackaton.
To train and use the the core of the system you need to follow the next steps.
"dependencies": [
{
"name": "pandas",
"version": "1.5.2"
},
{
"name": "scikit-learn",
"version": "1.2.0"
},
{
"name": "numpy",
"version": "1.23.5"
},
{
"name": "matplotlib",
"version": "3.6.2"
},
{
"name": "Flask",
"version": "2.2.2"
}
]
- Clone the repo
git clone https://github.com/ZhengLinLei/ZDMP.git
- Install components
git clone https://github.com/ZhengLinLei/ZDMP-datasets.git
git clone https://github.com/ZhengLinLei/ZDMP-client.git
- Install requirements
pip install -r requirements.txt
-
Get datasets and locate it into the datasets folder
-
Config the .ini
{
"dataset": {
"path": "datasets/batch_data.csv",
"name": "batch_data",
"predict": "datasets/predict.json",
"batch_size": 32,
"shuffle": true
},
"build": {
"path": "build",
"data": "data.png",
"model": "model.pkl",
"module": "pickle"
},
"server": {
"host": "127.0.0.1",
"port": 5000
}
}
To analyze the data run the below script, all analysis can be found in the src/
folder.
python src/data.py
And you will get the following output as image.
To get the best model run the below script, all models can be found in the src/models
folder.
python src/train_eval.py
After the training and evaluation process, the data will be printed.
Method Training MSE Training R2 Test MSE Test R2 Time
0 Linear regression 0.026466 0.651201 2603143596.200458 -34521933304.644592 4s
1 Random forest 0.054894 0.276561 0.053715 0.287655 1m 30s
2 KNNeighbors 0.000056 0.999266 0.014994 0.801152 1m 2s
3 SVM 0.044920 0.408009 0.043429 0.424063 6m 4s
After running the src/train_eval.py
script, the data sciencetist can choose the best model to train it.
Method Training MSE Training R2 Test MSE Test R2 Time
0 Linear regression 0.026466 0.651201 2603143596.200458 -34521933304.644592 4s ----> Worst model
1 Random forest 0.054894 0.276561 0.053715 0.287655 1m 30s
2 KNNeighbors 0.000056 0.999266 0.014994 0.801152 1m 2s ----> Best model
3 SVM 0.044920 0.408009 0.043429 0.424063 6m 4s
Change the model
variable in the src/train.py
file to the best model.
# Import KNN model
from models.KNNeighbors import KNNModel
# Create the model
model = KNNModel()
To train the model run the below script.
python src/train.py
The model trainned will be saved in the build
folder.
To run the server run the below script.
python src/
The server will listen all the request to make predictions. The source of code of prediction can be found in the src/predict.py
file.
# Create the route
@app.route('/predict', methods=['POST'])
def predict_api():
# Get the data
data = request.get_json(force=True)
# Make prediction
prediction = predict(data, os.path.join(CURRENT_PATH, CONFIG['model']['path']))
# Return the prediction
return jsonify(prediction)
Read the ZDMP-Client (Pending to be updated) repository to know how to run the client. The client will send the request to the python server to make predictions.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
How to contribute:
- Fork the Project
- Clone your repository (
git clone repo_url
) - Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the Apache 2.0 License. See LICENSE
for more information.
- Zheng Lin Lei - [email protected] | [email protected]
- Guillermo Breva de Dios - No contact available
- Elena Clofent Muñoz - No contact available
Project Link: https://github.com/ZhengLinLei/ZDMP
- ZDMP
- ZDMP-Datasets
- ZDMP-Client
- Hackaton 2022 - ZDMP