Srikanth0804 commited on
Commit
9e1c53d
Β·
verified Β·
1 Parent(s): 8dc9bb8

Update pages/3_Deployment.py

Browse files
Files changed (1) hide show
  1. pages/3_Deployment.py +52 -12
pages/3_Deployment.py CHANGED
@@ -9,23 +9,62 @@ st.title("🎯 Live Sentiment Classifier")
9
  with open("text_classification.pkl", "rb") as f:
10
  pipeline = pickle.load(f)
11
 
12
- # User input (updated label, placeholder, and help)
13
- user_input = st.text_area(
14
- "##### ✍️ Enter a YouTube comment related to one of the following topics:",
15
- placeholder="E.g., That reunion video was so emotional!",
16
- help="""
17
- **Trained Topics:**
18
-
19
- - 😊 Positive β†’ heartwarming reunion, kindness stories, feel-good moments
20
- - 😠 Negative β†’ bad customer experience, airline disaster, controversial news
21
- - 😐 Neutral β†’ latest tech review, travel vlog, gaming walkthrough
22
- """
23
- )
24
 
 
 
 
 
 
25
  if st.button("Predict Sentiment"):
26
  if user_input.strip():
27
  prediction = pipeline.predict([user_input])[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  st.markdown(f"## βœ… Prediction: `{prediction.capitalize()}`")
30
 
31
  if prediction == "positive":
@@ -37,5 +76,6 @@ if st.button("Predict Sentiment"):
37
  else:
38
  st.warning("⚠️ Please enter a comment to analyze.")
39
 
 
40
  if st.button("Go to Model Page"):
41
  st.switch_page("pages/2_Model_Training.py")
 
9
  with open("text_classification.pkl", "rb") as f:
10
  pipeline = pickle.load(f)
11
 
12
+ # Helpful context for users
13
+ st.markdown("#### πŸ“Œ *This model works best for YouTube comments related to the following topics:*")
14
+ st.markdown("""
15
+ - 😊 **Positive**: heartwarming reunion, kindness stories, feel-good moments
16
+ - 😠 **Negative**: bad customer experience, airline disaster, controversial incident
17
+ - 😐 **Neutral**: tech reviews, travel vlogs, gaming walkthroughs
18
+ """)
 
 
 
 
 
19
 
20
+ # User input
21
+ user_input = st.text_area("##### **Enter a YouTube comment to analyze:**",
22
+ placeholder="E.g., That reunion video was so emotional!")
23
+
24
+ # Predict button
25
  if st.button("Predict Sentiment"):
26
  if user_input.strip():
27
  prediction = pipeline.predict([user_input])[0]
28
+ st.markdown(f"## βœ… Prediction: `{prediction.capitalize()}`")
29
+
30
+ if prediction == "positive":
31
+ st.success("😊 Positive Sentiment")
32
+ elif prediction == "negative":
33
+ st.error("😠 Negative Sentiment")
34
+ else:
35
+ st.info("😐 Neutral Sentiment")
36
+ else:
37
+ st.warning("⚠️ Please enter a comment to analyze.")
38
+
39
+ # Navigation
40
+ if st.button("Go to Model Page"):
41
+ st.switch_page("pages/2_Model_Training.py")import streamlit as st
42
+ import pickle
43
 
44
+ st.set_page_config(page_title="🎯 YouTube Comment Sentiment Predictor")
45
+
46
+ st.title("🎯 Live Sentiment Classifier")
47
+
48
+ # Load the complete pipeline (TF-IDF + Model)
49
+ with open("text_classification.pkl", "rb") as f:
50
+ pipeline = pickle.load(f)
51
+
52
+ # Helpful context for users
53
+ st.markdown("#### πŸ“Œ *This model works best for YouTube comments related to the following topics:*")
54
+ st.markdown("""
55
+ - 😊 **Positive**: heartwarming reunion, kindness stories, feel-good moments
56
+ - 😠 **Negative**: bad customer experience, airline disaster, controversial incident
57
+ - 😐 **Neutral**: tech reviews, travel vlogs, gaming walkthroughs
58
+ """)
59
+
60
+ # User input
61
+ user_input = st.text_area("##### **Enter a YouTube comment to analyze:**",
62
+ placeholder="E.g., That reunion video was so emotional!")
63
+
64
+ # Predict button
65
+ if st.button("Predict Sentiment"):
66
+ if user_input.strip():
67
+ prediction = pipeline.predict([user_input])[0]
68
  st.markdown(f"## βœ… Prediction: `{prediction.capitalize()}`")
69
 
70
  if prediction == "positive":
 
76
  else:
77
  st.warning("⚠️ Please enter a comment to analyze.")
78
 
79
+ # Navigation
80
  if st.button("Go to Model Page"):
81
  st.switch_page("pages/2_Model_Training.py")