Snehangshu2002's picture
Update app.py
a7f96ed verified
import streamlit as st
import pickle
import numpy as np
with open("vectorizer_text.pkl", "rb") as f:
vectorizer_text = pickle.load(f)
with open("vectorizer_title.pkl", "rb") as f:
vectorizer_title = pickle.load(f)
with open("logistic_regression_model.pkl", "rb") as f:
logistic_regression_model = pickle.load(f)
# Streamlit app header
st.header("Fake News Prediction")
st.subheader("Created by Snehangshu Bhuin")
# Input fields for user
title = st.text_input("News Title")
text = st.text_area("Description")
# Prediction button
if st.button("Predict"):
# Transform the input text
title_transformed = vectorizer_title.transform([title])
text_transformed = vectorizer_text.transform([text])
input_features = np.hstack((title_transformed.toarray(), text_transformed.toarray()))
# Make prediction
prediction = logistic_regression_model.predict(input_features)
print(prediction)
# Display the prediction result
if prediction == 1:
st.success("The news is likely Real")
else:
st.error("The news is likely Fake")