File size: 636 Bytes
e513ac4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
import joblib

# Load model dan CountVectorizer
model = joblib.load('sentiment_model.pkl')
vectorizer = joblib.load('count_vectorizer.pkl')

# Fungsi untuk melakukan prediksi sentimen
def predict_sentiment(comment):
    comment_vec = vectorizer.transform([comment])
    prediction = model.predict(comment_vec)[0]
    return prediction

# Tampilan antarmuka Gradio
iface = gr.Interface(
    fn=predict_sentiment,
    inputs="textbox",
    outputs="label",
    title="Instagram Comment Sentiment Analysis",
    description="Enter an Instagram comment to predict its sentiment (Positive or Negative)."
)

iface.launch()