Rifqiakmals commited on
Commit
e513ac4
·
verified ·
1 Parent(s): ff880df

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+
4
+ # Load model dan CountVectorizer
5
+ model = joblib.load('sentiment_model.pkl')
6
+ vectorizer = joblib.load('count_vectorizer.pkl')
7
+
8
+ # Fungsi untuk melakukan prediksi sentimen
9
+ def predict_sentiment(comment):
10
+ comment_vec = vectorizer.transform([comment])
11
+ prediction = model.predict(comment_vec)[0]
12
+ return prediction
13
+
14
+ # Tampilan antarmuka Gradio
15
+ iface = gr.Interface(
16
+ fn=predict_sentiment,
17
+ inputs="textbox",
18
+ outputs="label",
19
+ title="Instagram Comment Sentiment Analysis",
20
+ description="Enter an Instagram comment to predict its sentiment (Positive or Negative)."
21
+ )
22
+
23
+ iface.launch()