import streamlit as st import pickle st.set_page_config(page_title="🎯 YouTube Comment Sentiment Predictor") st.title("🎯 Live Sentiment Classifier") # Load the complete pipeline (TF-IDF + Model) with open("text_classification.pkl", "rb") as f: pipeline = pickle.load(f) # Helpful context for users with st.expander("#### 📌 **Click here to see what topics this model was trained on**"): st.markdown(""" - **heartwarming reunion, kindness stories, feel-good moments** - **bad customer experience, airline disaster, controversial incidents** - **tech reviews, travel vlogs, gaming walkthroughs** """) # User input user_input = st.text_area("##### **Enter a YouTube comment to analyze:**", placeholder="E.g., That reunion video was so emotional!") # Predict button if st.button("Predict Sentiment"): if user_input.strip(): prediction = pipeline.predict([user_input])[0] st.markdown(f"## ✅ Prediction: `{prediction.capitalize()}`") if prediction == "positive": st.success("😊 Positive Sentiment") elif prediction == "negative": st.error("😠 Negative Sentiment") else: st.info("😐 Neutral Sentiment") else: st.warning("⚠️ Please enter a comment to analyze.") # Navigation if st.button("Go to Model Page"): st.switch_page("pages/2_Model_Training.py")