Srikanth0804 commited on
Commit
00b712f
·
verified ·
1 Parent(s): 15cfc3d

Create pages/3_Deployment.py

Browse files
Files changed (1) hide show
  1. pages/3_Deployment.py +31 -0
pages/3_Deployment.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+
4
+ st.set_page_config(page_title="🎯 YouTube Comment Sentiment Predictor")
5
+
6
+ st.title("🎯 Live Sentiment Classifier")
7
+
8
+ # Load the complete pipeline (TF-IDF + Model)
9
+ with open("text_classification.pkl", "rb") as f:
10
+ pipeline = pickle.load(f)
11
+
12
+ # User input
13
+ user_input = st.text_area("*Enter a YouTube comment to analyze:*")
14
+
15
+ if st.button("Predict Sentiment"):
16
+ if user_input.strip():
17
+ prediction = pipeline.predict([user_input])[0]
18
+
19
+ st.markdown(f"## ✅ Prediction: `{prediction.capitalize()}`")
20
+
21
+ if prediction == "positive":
22
+ st.success("😊 Positive Sentiment")
23
+ elif prediction == "negative":
24
+ st.error("😠 Negative Sentiment")
25
+ else:
26
+ st.info("😐 Neutral Sentiment")
27
+ else:
28
+ st.warning("⚠️ Please enter a comment to analyze.")
29
+
30
+ if st.button("Go to Model Page"):
31
+ st.switch_page("pages/2_Model_Training.py")