Actualización de modelo
Browse files- config.json +8 -18
- inference.py +15 -32
- model.pkl +1 -1
- vectorizer.pkl +1 -1
config.json
CHANGED
@@ -1,20 +1,10 @@
|
|
1 |
{
|
2 |
-
"
|
3 |
-
"model_type": "
|
4 |
-
"
|
5 |
-
"
|
6 |
"language": "es",
|
7 |
-
"
|
8 |
-
"
|
9 |
-
"
|
10 |
-
|
11 |
-
"vocab_size": 30522,
|
12 |
-
"hidden_size": 768,
|
13 |
-
"intermediate_size": 3072,
|
14 |
-
"hidden_act": "gelu",
|
15 |
-
"hidden_dropout_prob": 0.1,
|
16 |
-
"attention_probs_dropout_prob": 0.1,
|
17 |
-
"max_length": 100,
|
18 |
-
"do_sample": true,
|
19 |
-
"num_return_sequences": 1
|
20 |
-
}
|
|
|
1 |
{
|
2 |
+
"model_name": "Spanish Text Classification Model",
|
3 |
+
"model_type": "sklearn",
|
4 |
+
"framework": "sklearn",
|
5 |
+
"task": "text-classification",
|
6 |
"language": "es",
|
7 |
+
"vectorizer": "TfidfVectorizer",
|
8 |
+
"classifier": "MultinomialNB",
|
9 |
+
"version": "1.0.0"
|
10 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inference.py
CHANGED
@@ -1,37 +1,20 @@
|
|
1 |
-
import joblib
|
2 |
-
import numpy as np
|
3 |
-
|
4 |
-
# Cargar el vectorizador
|
5 |
-
try:
|
6 |
-
with open('vectorizer.pkl', 'rb') as f:
|
7 |
-
vectorizer = joblib.load(f)
|
8 |
-
except Exception as e:
|
9 |
-
print(f"Error al cargar el vectorizador: {e}")
|
10 |
|
11 |
-
|
12 |
-
try:
|
13 |
-
with open('model.pkl', 'rb') as f:
|
14 |
-
model = joblib.load(f)
|
15 |
-
except Exception as e:
|
16 |
-
print(f"Error al cargar el modelo: {e}")
|
17 |
|
18 |
-
def
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
except Exception as e:
|
23 |
-
print(f"Error en el preprocesamiento: {e}")
|
24 |
|
25 |
def predict(text):
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
except Exception as e:
|
31 |
-
print(f"Error en la predicción: {e}")
|
32 |
|
33 |
-
if __name__ ==
|
34 |
-
#
|
35 |
-
|
36 |
-
result = predict(
|
37 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
+
import joblib
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
def load_model_and_vectorizer():
|
5 |
+
model = joblib.load('model.pkl')
|
6 |
+
vectorizer = joblib.load('vectorizer.pkl')
|
7 |
+
return model, vectorizer
|
|
|
|
|
8 |
|
9 |
def predict(text):
|
10 |
+
model, vectorizer = load_model_and_vectorizer()
|
11 |
+
text_vectorized = vectorizer.transform([text])
|
12 |
+
prediction = model.predict(text_vectorized)
|
13 |
+
return prediction[0]
|
|
|
|
|
14 |
|
15 |
+
if __name__ == '__main__':
|
16 |
+
# Example usage
|
17 |
+
text = "Ejemplo de declaraci�n"
|
18 |
+
result = predict(text)
|
19 |
+
print(f"Categor�a predicha: {result}")
|
20 |
+
|
model.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 7103071
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e5910e6d9fdc5fd8f6ed1cceeda5bfb8dac91905e61c0bd01dbf7a6c39b416f6
|
3 |
size 7103071
|
vectorizer.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 1123551
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d38d53585deb8d0789ce2a229e8a000849900a1cedf8c91b9c9d7d1d2f76cfb
|
3 |
size 1123551
|