import pandas as pd import numpy as np import re import streamlit as st import joblib import numpy as np import pandas as pd st.markdown(f""" """, unsafe_allow_html=True) html_temp = """

Chat GPT Review Prediction

""" st.markdown(html_temp, unsafe_allow_html=True) image_url="https://storage.googleapis.com/kaggle-datasets-images/6377125/10302664/91e3eb67027ab3122886b971613e7c2f/dataset-cover.jpg?t=2024-12-26-10-34-17" st.image(image_url, use_container_width=True) input_txt=st.text_input("Enter the Review") # preprocess the text def preprocess_text(text): text = text.lower() text = re.sub(r'\d+', '', text) text = re.sub(r'[^\w\s]', '', text) text = re.sub(r'\s+', ' ', text) return text # loading the models loaded_tfidf = joblib.load("tfidf_model.joblib") model = joblib.load("chat_review_model.joblib") # processing if input: test=preprocess_text(input_txt) label=loaded_tfidf.transform([test]) # Predict and display the result if st.button("Submit"): try: # Get prediction from the model prediction = model.predict(label)[0] # Define messages and colors review_status = { 1: ("✅ It is a Good Review!", "#32CD32"), # Green 0: ("❌ It is a Bad Review!", "#FF4500") # Red-Orange } # Get message and color based on prediction message, color = review_status.get(prediction, ("❓ Unknown Prediction", "#808080")) # Display styled result st.markdown(f"""
{message}
""", unsafe_allow_html=True) except Exception as e: st.error(f"⚠️ Error in prediction: {e}") st.write("")