Subida inicial del modelo
Browse files- .gitattributes +0 -35
- inference.py +20 -7
- requirements.txt +2 -1
.gitattributes
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inference.py
CHANGED
@@ -1,15 +1,28 @@
|
|
1 |
-
import
|
|
|
2 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
3 |
|
4 |
-
# Cargar el
|
5 |
with open('vectorizer.pkl', 'rb') as f:
|
6 |
-
vectorizer =
|
7 |
|
|
|
8 |
with open('model.pkl', 'rb') as f:
|
9 |
-
model =
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def predict(text):
|
12 |
-
|
13 |
-
X =
|
14 |
-
#
|
15 |
return model.predict(X)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import numpy as np
|
3 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
|
5 |
+
# Cargar el vectorizador usando joblib
|
6 |
with open('vectorizer.pkl', 'rb') as f:
|
7 |
+
vectorizer = joblib.load(f)
|
8 |
|
9 |
+
# Cargar el modelo usando joblib
|
10 |
with open('model.pkl', 'rb') as f:
|
11 |
+
model = joblib.load(f)
|
12 |
+
|
13 |
+
def preprocess(text):
|
14 |
+
"""Preprocesa el texto para la inferencia."""
|
15 |
+
# Transformar el texto usando el vectorizador cargado
|
16 |
+
return vectorizer.transform([text])
|
17 |
|
18 |
def predict(text):
|
19 |
+
"""Realiza la predicción a partir del texto ingresado."""
|
20 |
+
X = preprocess(text)
|
21 |
+
# Realizar la predicción usando el modelo cargado
|
22 |
return model.predict(X)
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
# Probar el modelo con un texto de ejemplo
|
26 |
+
test_text = "Este es un ejemplo de texto para predecir"
|
27 |
+
result = predict(test_text)
|
28 |
+
print(f"Predicción: {result}")
|
requirements.txt
CHANGED
@@ -2,4 +2,5 @@ pandas
|
|
2 |
scikit-learn
|
3 |
imbalanced-learn
|
4 |
joblib
|
5 |
-
numpy
|
|
|
|
2 |
scikit-learn
|
3 |
imbalanced-learn
|
4 |
joblib
|
5 |
+
numpy
|
6 |
+
pickle
|