Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- app.py +21 -0
- nb_classifier.pkl +3 -0
- requirements.txt +3 -0
- tfidf_vectorizer.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
nb_classifier = joblib.load('nb_classifier.pkl')
|
| 6 |
+
tfidf_vectorizer = joblib.load('tfidf_vectorizer.pkl')
|
| 7 |
+
|
| 8 |
+
def predict_sentiment(text):
|
| 9 |
+
text_tfidf = tfidf_vectorizer.transform([text])
|
| 10 |
+
predicted_sentiment = nb_classifier.predict(text_tfidf)[0]
|
| 11 |
+
return predicted_sentiment
|
| 12 |
+
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=predict_sentiment,
|
| 15 |
+
inputs="text",
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Sentiment Analysis",
|
| 18 |
+
description="Predict sentiment of a text message.",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
iface.launch(share=True)
|
nb_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c091be62a0ddea7ab73711659205046a13bf98dcea6221d5ca6ec27d39a6ac61
|
| 3 |
+
size 1395119
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
joblib
|
| 3 |
+
scikit-learn
|
tfidf_vectorizer.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d8cdea87fdf62efd72f59558b88b4429fc31aced7805ea0e9521be4d7ce3dfdd
|
| 3 |
+
size 840161
|