File size: 557 Bytes
aca2f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f0ee73
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

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])}