import pickle | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
# Cargar el modelo y el vectorizador | |
with open('vectorizer.pkl', 'rb') as f: | |
vectorizer = pickle.load(f) | |
with open('model.pkl', 'rb') as f: | |
model = pickle.load(f) | |
def predict(text): | |
# Preprocesar el texto usando el vectorizador | |
X = vectorizer.transform([text]) | |
# Hacer una predicción usando el modelo | |
return model.predict(X) | |