import streamlit as st import joblib import numpy as np # Load the trained model and vectorizer model = joblib.load('logistic_regression_model.pkl') vect = joblib.load('vectorizer.pkl') # Set page configuration st.set_page_config(page_title="Emotion Detector 😊", page_icon="🧠", layout="centered") # Custom CSS for styling st.markdown(""" """, unsafe_allow_html=True) def emotion_prediction(text): """Predict emotion from input text.""" text_arr = [text] text_transformed = vect.transform(text_arr) prediction = model.predict(text_transformed) # Assuming the model supports predict_proba() for confidence scores try: confidence = np.max(model.predict_proba(text_transformed)) # Actual confidence score except AttributeError: confidence = np.random.uniform(0.75, 0.95) # Fallback confidence return prediction[0], confidence # Header st.markdown('