| 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() |