Alexvatti's picture
Upload app.py
818a28f verified
Raw
History Blame Contribute Delete
1.25 kB
import pandas as pd
import numpy as np
import re
import streamlit as st
import joblib
import numpy as np
import pandas as pd
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")
# 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
if st.button("Submit"):
predict=model.predict(label)[0]
if predict==1:
st.write("Its is a Good Review")
elif predict==0:
st.write("Its is a Bad Review")