Spaces:
Sleeping
Sleeping
Update pages/3_Deployment.py
Browse files- 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 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
**
|
| 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")
|