Spaces:
Sleeping
Sleeping
SuperViktor2
commited on
Commit
•
cf1ce0f
1
Parent(s):
9a62f4c
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,12 @@ from sklearn.feature_extraction.text import TfidfVectorizer
|
|
6 |
|
7 |
os.environ["WANDB_DISABLED"] = "true"
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
model_file_name = "xgb_reg.pkl"
|
10 |
vectorizer_file_name = 'vectorizer.pk'
|
11 |
|
@@ -15,10 +21,9 @@ vectorizer_loaded = pickle.load(open(vectorizer_file_name, "rb"))
|
|
15 |
|
16 |
# predict
|
17 |
def predict_sentiment(predict_texts):
|
18 |
-
predictions_loaded = xgb_model_loaded.predict(
|
19 |
-
|
20 |
-
return
|
21 |
-
#le.inverse_transform(predictions_loaded)
|
22 |
|
23 |
interface = gr.Interface(
|
24 |
fn=predict_sentiment,
|
|
|
6 |
|
7 |
os.environ["WANDB_DISABLED"] = "true"
|
8 |
|
9 |
+
label2id = {
|
10 |
+
0: "negative",
|
11 |
+
1: "neutral",
|
12 |
+
2: "positive"
|
13 |
+
}
|
14 |
+
|
15 |
model_file_name = "xgb_reg.pkl"
|
16 |
vectorizer_file_name = 'vectorizer.pk'
|
17 |
|
|
|
21 |
|
22 |
# predict
|
23 |
def predict_sentiment(predict_texts):
|
24 |
+
predictions_loaded = xgb_model_loaded.predict(vectorizer_loaded.transform([predict_texts]))
|
25 |
+
print(predictions_loaded)
|
26 |
+
return label2id[predictions_loaded[0]]
|
|
|
27 |
|
28 |
interface = gr.Interface(
|
29 |
fn=predict_sentiment,
|