Snehangshu2002
commited on
Commit
•
a7f96ed
1
Parent(s):
62d7a00
Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pickle
|
3 |
-
import numpy as np
|
4 |
-
|
5 |
-
|
6 |
-
with open("
|
7 |
-
vectorizer_text = pickle.load(f)
|
8 |
-
|
9 |
-
with open("
|
10 |
-
vectorizer_title = pickle.load(f)
|
11 |
-
|
12 |
-
with open("
|
13 |
-
logistic_regression_model = pickle.load(f)
|
14 |
-
|
15 |
-
|
16 |
-
# Streamlit app header
|
17 |
-
st.header("Fake News Prediction")
|
18 |
-
st.subheader("Created by Snehangshu Bhuin")
|
19 |
-
|
20 |
-
# Input fields for user
|
21 |
-
title = st.text_input("News Title")
|
22 |
-
text = st.text_area("Description")
|
23 |
-
|
24 |
-
# Prediction button
|
25 |
-
if st.button("Predict"):
|
26 |
-
# Transform the input text
|
27 |
-
title_transformed = vectorizer_title.transform([title])
|
28 |
-
text_transformed = vectorizer_text.transform([text])
|
29 |
-
|
30 |
-
|
31 |
-
input_features = np.hstack((title_transformed.toarray(), text_transformed.toarray()))
|
32 |
-
|
33 |
-
# Make prediction
|
34 |
-
prediction = logistic_regression_model.predict(input_features)
|
35 |
-
print(prediction)
|
36 |
-
# Display the prediction result
|
37 |
-
if prediction == 1:
|
38 |
-
st.success("The news is likely Real")
|
39 |
-
else:
|
40 |
st.error("The news is likely Fake")
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pickle
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
|
6 |
+
with open("vectorizer_text.pkl", "rb") as f:
|
7 |
+
vectorizer_text = pickle.load(f)
|
8 |
+
|
9 |
+
with open("vectorizer_title.pkl", "rb") as f:
|
10 |
+
vectorizer_title = pickle.load(f)
|
11 |
+
|
12 |
+
with open("logistic_regression_model.pkl", "rb") as f:
|
13 |
+
logistic_regression_model = pickle.load(f)
|
14 |
+
|
15 |
+
|
16 |
+
# Streamlit app header
|
17 |
+
st.header("Fake News Prediction")
|
18 |
+
st.subheader("Created by Snehangshu Bhuin")
|
19 |
+
|
20 |
+
# Input fields for user
|
21 |
+
title = st.text_input("News Title")
|
22 |
+
text = st.text_area("Description")
|
23 |
+
|
24 |
+
# Prediction button
|
25 |
+
if st.button("Predict"):
|
26 |
+
# Transform the input text
|
27 |
+
title_transformed = vectorizer_title.transform([title])
|
28 |
+
text_transformed = vectorizer_text.transform([text])
|
29 |
+
|
30 |
+
|
31 |
+
input_features = np.hstack((title_transformed.toarray(), text_transformed.toarray()))
|
32 |
+
|
33 |
+
# Make prediction
|
34 |
+
prediction = logistic_regression_model.predict(input_features)
|
35 |
+
print(prediction)
|
36 |
+
# Display the prediction result
|
37 |
+
if prediction == 1:
|
38 |
+
st.success("The news is likely Real")
|
39 |
+
else:
|
40 |
st.error("The news is likely Fake")
|