Added logistic regression language classifier model
Browse files- inference.py +15 -0
- requirements.txt +3 -0
inference.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import joblib
|
| 3 |
+
from sklearn.pipeline import Pipeline
|
| 4 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 5 |
+
from sklearn.linear_model import LogisticRegression
|
| 6 |
+
from typing import List
|
| 7 |
+
|
| 8 |
+
# Загрузка модели
|
| 9 |
+
model_path = "model/language_classifier.joblib"
|
| 10 |
+
model = joblib.load(model_path)
|
| 11 |
+
|
| 12 |
+
# Функция для предсказания
|
| 13 |
+
def predict(texts: List[str]):
|
| 14 |
+
predictions = model.predict(texts)
|
| 15 |
+
return predictions
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
scikit-learn
|
| 3 |
+
joblib
|