Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import joblib
|
| 3 |
-
|
| 4 |
-
# Load model & vectorizer
|
| 5 |
-
model = joblib.load("
|
| 6 |
-
tfidf = joblib.load("tfidf_vectorizer.joblib")
|
| 7 |
-
|
| 8 |
-
def predict_sentiment(text):
|
| 9 |
-
vector = tfidf.transform([text])
|
| 10 |
-
prediction = model.predict(vector)[0]
|
| 11 |
-
label = "✅ Positive" if prediction == 1 else "❌ Negative"
|
| 12 |
-
return label
|
| 13 |
-
|
| 14 |
-
iface = gr.Interface(
|
| 15 |
-
fn=predict_sentiment,
|
| 16 |
-
inputs=gr.Textbox(label="Enter a Review"),
|
| 17 |
-
outputs=gr.Textbox(label="Sentiment"),
|
| 18 |
-
title="XGBoost Sentiment Classifier",
|
| 19 |
-
description="Real-time sentiment analysis using TF-IDF + XGBoost."
|
| 20 |
-
)
|
| 21 |
-
|
| 22 |
-
iface.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import joblib
|
| 3 |
+
|
| 4 |
+
# Load model & vectorizer
|
| 5 |
+
model = joblib.load("sentiment_model.joblib")
|
| 6 |
+
tfidf = joblib.load("tfidf_vectorizer.joblib")
|
| 7 |
+
|
| 8 |
+
def predict_sentiment(text):
|
| 9 |
+
vector = tfidf.transform([text])
|
| 10 |
+
prediction = model.predict(vector)[0]
|
| 11 |
+
label = "✅ Positive" if prediction == 1 else "❌ Negative"
|
| 12 |
+
return label
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=predict_sentiment,
|
| 16 |
+
inputs=gr.Textbox(label="Enter a Review"),
|
| 17 |
+
outputs=gr.Textbox(label="Sentiment"),
|
| 18 |
+
title="XGBoost Sentiment Classifier",
|
| 19 |
+
description="Real-time sentiment analysis using TF-IDF + XGBoost."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
iface.launch()
|