File size: 1,422 Bytes
00b712f
 
 
 
 
 
 
 
 
 
 
9e1c53d
68f05b0
 
4583da0
 
 
68f05b0
9e1c53d
 
 
 
 
 
 
 
 
00b712f
 
 
 
 
 
 
 
 
 
 
9e1c53d
00b712f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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")