Nihal2003/customer_feedback_classification
0
1import streamlit as st2import pickle3 4# ---------------------------5# Load TF-IDF and Model6# ---------------------------7def load_artifacts():8 with open("tfidf.pkl", "rb") as f:9 tfidf = pickle.load(f)10 11 with open("model.pkl", "rb") as f:12 model = pickle.load(f)13 14 return tfidf, model15 16# ---------------------------17# Main UI18# ---------------------------19def main():20 21 st.set_page_config(page_title="Sentiment Classifier", page_icon="๐ฌ")22 23 st.title("๐ฌ Customer Feedback Sentiment Classifier")24 25 st.write("Type your sentence and click **Proceed** for sentiment prediction.")26 27 tfidf, model = load_artifacts()28 29 text = st.text_area("Enter your sentence:", height=150)30 31 # LABEL MAPPING32 label_map = {33 0: "NEGATIVE",34 1: "NEUTRAL",35 2: "POSITIVE"36 }37 38 if st.button("Proceed"):39 40 if text.strip() == "":41 st.warning("โ ๏ธ Please enter some text.")42 else:43 vec = tfidf.transform([text])44 prediction = model.predict(vec)[0]45 46 # Convert numeric โ string label47 result = label_map[int(prediction)]48 49 # RED COLOR + BIG FONT50 st.markdown(51 f"""52 <h1 style='text-align:center; color:red; font-size:40px; font-weight:700;'>53 {result}54 </h1>55 """,56 unsafe_allow_html=True57 )58 59if __name__ == "__main__":60 main()61 