| | 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""" |
| | <style> |
| | /* Set the background image for the entire app */ |
| | .stApp {{ |
| | background-color: #BA944E; |
| | background-size: 100px; |
| | background-repeat:no; |
| | background-attachment: auto; |
| | background-position:full; |
| | }} |
| | </style> |
| | """, unsafe_allow_html=True) |
| | |
| |
|
| | html_temp = """ |
| | <div style="background-color:black;padding:10px"> |
| | <h2 style="color:white;text-align:center;">Chat GPT Review Prediction </h2> |
| | </div> |
| | """ |
| | 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") |
| |
|
| |
|
| | |
| |
|
| | 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 |
| |
|
| | |
| | loaded_tfidf = joblib.load("tfidf_model.joblib") |
| | model = joblib.load("chat_review_model.joblib") |
| |
|
| | |
| | if input: |
| | test=preprocess_text(input_txt) |
| | label=loaded_tfidf.transform([test]) |
| |
|
| | |
| | if st.button("Submit"): |
| | try: |
| | |
| | prediction = model.predict(label)[0] |
| |
|
| | |
| | review_status = { |
| | 1: ("✅ It is a Good Review!", "#32CD32"), |
| | 0: ("❌ It is a Bad Review!", "#FF4500") |
| | } |
| |
|
| | |
| | message, color = review_status.get(prediction, ("❓ Unknown Prediction", "#808080")) |
| |
|
| | |
| | st.markdown(f""" |
| | <div style=" |
| | padding: 15px; |
| | background-color: {color}; |
| | border-radius: 10px; |
| | text-align: center; |
| | font-size: 18px; |
| | font-weight: bold; |
| | color: white;"> |
| | {message} |
| | </div> |
| | """, unsafe_allow_html=True) |
| |
|
| | except Exception as e: |
| | st.error(f"⚠️ Error in prediction: {e}") |
| |
|
| | st.write("") |
| |
|