import streamlit as st import joblib # Load saved models TF_IDF = joblib.load('tfidf_vectorizer.pkl') svd = joblib.load('dimensionality_reduction.pkl') RF = joblib.load('random_forest_model.pkl') # Custom CSS for styling st.markdown( """ """, unsafe_allow_html=True ) # Streamlit App st.title(" Classify Game Feedback") st.write("Enter text below to classify:") # Text input from the user user_input = st.text_area("Input Text", "", key="input_text", help="Type your game review here.") # Center the predict button col1, col2, col3 = st.columns([1,2,1]) with col2: if st.button("Predict"): if user_input.strip() == "": st.warning("Please enter some text to classify.") else: # Transform the input text tfidf_input = TF_IDF.transform([user_input]) reduced_input = svd.transform(tfidf_input) # Make prediction prediction = RF.predict(reduced_input)[0] prediction_proba = RF.predict_proba(reduced_input)[0] confidence = max(prediction_proba) * 100 if prediction == 1: sentiment = "Positive" insight = "Users appreciate the engaging gameplay and storyline." else: sentiment = "Negative" insight = "Feedback suggests concerns about game performance and frequent bugs." # Display the prediction with additional context st.success(f"The review is **{sentiment}** with a confidence score of {confidence:.2f}%.") st.info(f"*Insight:* {insight}")