Commit ·
5cf607d
1
Parent(s): aa015be
Upload model_wrapper.py with huggingface_hub
Browse files- model_wrapper.py +17 -0
model_wrapper.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# model_wrapper.py
|
| 2 |
+
|
| 3 |
+
import joblib
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
LABELS = ['admiration','anger','disgust','fear','hope',
|
| 7 |
+
'joy','love','pride','sadness']
|
| 8 |
+
|
| 9 |
+
class MyModel:
|
| 10 |
+
def __init__(self):
|
| 11 |
+
bundle = joblib.load("model.pkl")
|
| 12 |
+
self.vectorizer = bundle["vectorizer"]
|
| 13 |
+
self.classifier = bundle["classifier"]
|
| 14 |
+
|
| 15 |
+
def predict(self, texts):
|
| 16 |
+
X = self.vectorizer.transform(texts)
|
| 17 |
+
return self.classifier.predict(X)
|