|
import pickle |
|
|
|
import streamlit as st |
|
|
|
from preprocessing import data_preprocessing |
|
|
|
|
|
with open("vectorizer.pkl", "rb") as f: |
|
vectorizer = pickle.load(f) |
|
|
|
|
|
with open("logreg_model.pkl", "rb") as f: |
|
logreg = pickle.load(f) |
|
|
|
|
|
|
|
def preprocess_text(text): |
|
|
|
clean_text = data_preprocessing( |
|
text |
|
) |
|
print("Clean text ", clean_text) |
|
vectorized_text = vectorizer.transform([" ".join(clean_text)]) |
|
return vectorized_text |
|
|
|
|
|
|
|
def predict_sentiment(text): |
|
|
|
processed_text = preprocess_text(text) |
|
print(preprocess_text) |
|
|
|
prediction = logreg.predict(processed_text) |
|
return prediction |
|
|
|
|
|
|
|
st.title("Sentiment Analysis with Logistic Regression") |
|
text_input = st.text_input("Enter your review:") |
|
if st.button("Predict"): |
|
st.write("Knopka") |
|
prediction = predict_sentiment(text_input) |
|
st.write("prediction") |
|
st.write("Predicted Sentiment:", prediction) |
|
|