import streamlit as st
import joblib
import numpy as np
# Load model and vectorizer
model = joblib.load('logistic_regression_model.pkl')
vect = joblib.load('vectorizer.pkl')
def sentiment_prediction(text):
text_arr = [text]
text_transformed = vect.transform(text_arr)
prediction = model.predict(text_transformed)
return prediction
def main():
st.set_page_config(page_title="🎬 Movie Review Sentiment Analysis", page_icon="🎭", layout="wide")
# Custom CSS for stylish UI
st.markdown("""
""", unsafe_allow_html=True)
# App Title
st.markdown('
🎬 Movie Review Sentiment Analysis
', unsafe_allow_html=True)
st.markdown('Analyze movie reviews using AI-powered sentiment prediction
', unsafe_allow_html=True)
# Input Section with Styling
with st.container():
st.markdown('', unsafe_allow_html=True)
text = st.text_area("Type your review", "", height=150)
st.markdown('
', unsafe_allow_html=True)
# Prediction button with custom style
if st.button("🔮 Predict Sentiment"):
if text.strip() == "":
st.warning("⚠️ Please enter some text to make a prediction!")
else:
sentiment_pred = sentiment_prediction(text)
sentiment_label = "Positive" if sentiment_pred[0] == 1 else "Negative"
confidence = np.random.uniform(0.75, 0.95) # Fake confidence score (replace with actual if available)
# Result visualization with fancy effects
result_class = "positive" if sentiment_pred[0] == 1 else "negative"
st.markdown(f'🎭 Prediction: {sentiment_label}
', unsafe_allow_html=True)
st.markdown(f'✨ Confidence: {confidence:.2f}
', unsafe_allow_html=True)
if __name__ == "__main__":
main()