Gustavo commited on
Commit
1bcc547
1 Parent(s): 65f3585

commit inicial

Browse files
Files changed (4) hide show
  1. .gitignore +126 -0
  2. README.md +30 -0
  3. app.py +64 -0
  4. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ pytestdebug.log
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # pyenv
82
+ .python-version
83
+
84
+ # celery beat schedule files
85
+ celerybeat-schedule
86
+ celerybeat.pid
87
+
88
+ # SageMath parsed files
89
+ *.sage.py
90
+
91
+ # Environments
92
+ .env
93
+ .venv
94
+ env/
95
+ venv/
96
+ ENV/
97
+ env.bak/
98
+ venv.bak/
99
+
100
+ # Spyder project settings
101
+ .spyderproject
102
+ .spyproject
103
+
104
+ # Rope project settings
105
+ .ropeproject
106
+
107
+ # mkdocs documentation
108
+ /site
109
+
110
+ # mypy
111
+ .mypy_cache/
112
+ .dmypy.json
113
+ dmypy.json
114
+
115
+ # Pyre type checker
116
+ .pyre/
117
+
118
+ # profiling files
119
+ .prof
120
+
121
+ # VSCode settings
122
+ .vscode/
123
+
124
+ # Data files
125
+ *.joblib
126
+ *.pkl
README.md CHANGED
@@ -9,4 +9,34 @@ app_file: app.py
9
  pinned: false
10
  ---
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
9
  pinned: false
10
  ---
11
 
12
+ # Cluster Prediction Model Deployment
13
+
14
+ ## Overview
15
+ This application uses a machine learning model to predict the operation cluster of machinery based on input features. It is built using Gradio and hosted on Hugging Face Spaces for easy access and interaction.
16
+
17
+ ## Features
18
+ The application accepts the following features to make predictions:
19
+ - RPM (Revoluciones Por Minuto del equipo)
20
+ - Aceleraci贸n_LA (Aceleraci贸n Lado del Acople)
21
+ - Velocidad_LA (Velocidad Lado del Acople)
22
+ - Envolvente_LA (Envolvente Lado del Acople)
23
+ - Aceleraci贸n_LI (Aceleraci贸n Lado del Impulsor)
24
+ - Velocidad_LI (Velocidad Lado del Impulsor)
25
+ - Envolvente_LI (Envolvente Lado del Impulsor)
26
+ - Horas_Op (OHoras de Operaci贸n)
27
+
28
+ ## Cluster Definitions
29
+ - 0: Operaci贸n Cr铆tica (Critical Operation)
30
+ - 1: Operaci贸n Sub-贸ptima (Sub-optimal Operation)
31
+ - 2: Operaci贸n Normal (Normal Operation)
32
+
33
+ ## How to Use
34
+ Enter the values for each feature as instructed in the interface and click the 'Submit' button to see the predicted operation condition.
35
+
36
+ ## Deployment
37
+ This application is hosted on Hugging Face Spaces, allowing for easy access and interactive use through a web-based interface.
38
+
39
+ Enjoy interacting with the model!
40
+
41
+
42
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Clustering Use_model_cloud.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/19dFamN4Td92NqjpOmSrTE7L1kyiZtmTk
8
+ """
9
+
10
+ import os
11
+ import joblib
12
+
13
+ """# **Web/API deployment**
14
+
15
+ ## **Serialize the Model**
16
+ """
17
+
18
+ saved_model_path = "/OperationCondition/files/prueba_clustering.joblib"
19
+
20
+ os.path.getsize(saved_model_path)
21
+
22
+ saved_model = joblib.load("/OperationCondition/files/prueba_clustering.joblib")
23
+
24
+ saved_model
25
+
26
+ """## **Write a Model Server**"""
27
+
28
+
29
+ """### Define Function for Prediction"""
30
+
31
+ import numpy as np
32
+
33
+ def predict_cluster(RPM, Aceleraci贸n_LA, Velocidad_LA, Envolvente_LA, Aceleraci贸n_LI, Velocidad_LI, Envolvente_LI, Horas_Op):
34
+ # Asume que el modelo necesita un array de numpy con una fila de features
35
+ input_features = np.array([RPM, Aceleraci贸n_LA, Velocidad_LA, Envolvente_LA, Aceleraci贸n_LI, Velocidad_LI, Envolvente_LI, Horas_Op]).reshape(1, -1)
36
+ cluster_number = saved_model.predict(input_features)[0]
37
+ # Mapeo de n煤mero de cluster a nombre de cluster
38
+ cluster_names = {0: "Operaci贸n Cr铆tica", 1: "Operaci贸n Sub-贸ptima", 2: "Operaci贸n Normal"}
39
+ cluster_name = cluster_names.get(cluster_number, "Cluster no identificado")
40
+ return f"El cluster predicho es: {cluster_name}"
41
+
42
+ """### Create Interface"""
43
+
44
+ import gradio as gr
45
+
46
+ iface = gr.Interface(
47
+ fn=predict_cluster,
48
+ inputs=[
49
+ gr.Number(label="RPM"),
50
+ gr.Number(label="Aceleraci贸n_LA"),
51
+ gr.Number(label="Velocidad_LA"),
52
+ gr.Number(label="Envolvente_LA"),
53
+ gr.Number(label="Aceleraci贸n_LI"),
54
+ gr.Number(label="Velocidad_LI"),
55
+ gr.Number(label="Envolvente_LI"),
56
+ gr.Number(label="Horas_Op")
57
+ ],
58
+ outputs="text",
59
+ title="Predicci贸n de Condici贸n de Operaci贸n del Activo",
60
+ description="Introduce los valores de las caracter铆sticas del motor para predecir la condici贸n."
61
+ )
62
+
63
+ # Lanzar la aplicaci贸n de Gradio
64
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ numpy
3
+ scikit-learn
4
+ joblib