File size: 1,092 Bytes
a7f96ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5675707
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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")