Nadun102 commited on
Commit
1ca8529
·
verified ·
1 Parent(s): 419700d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -1,22 +1,22 @@
1
- import gradio as gr
2
- import joblib
3
-
4
- # Load model & vectorizer
5
- model = joblib.load("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()
 
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()