import joblib | |
from sklearn.pipeline import Pipeline | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.linear_model import LogisticRegression | |
from typing import List | |
# Загрузка модели | |
model_path = "model/language_classifier.joblib" | |
model = joblib.load(model_path) | |
# Функция для предсказания | |
def predict(texts: List[str]): | |
predictions = model.predict(texts) | |
return predictions | |
def preprocess(text): | |
return [text] | |
def postprocess(prediction): | |
return {"label": int(prediction[0])} | |