-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (35 loc) · 1.21 KB
/
app.py
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
41
42
import streamlit as st
import joblib
import re
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer
from sklearn.feature_extraction.text import TfidfVectorizer
port_stem = PorterStemmer()
vectorization = TfidfVectorizer()
vector_form = joblib.load('vector.joblib')
load_model = joblib.load('model.joblib')
def stemming(content):
con=re.sub('[^a-zA-Z]', ' ', content)
con=con.lower()
con=con.split()
con=[port_stem.stem(word) for word in con if not word in stopwords.words('english')]
con=' '.join(con)
return con
def fake_news(news):
news=stemming(news)
input_data=[news]
vector_form1=vector_form.transform(input_data)
prediction = load_model.predict(vector_form1)
return prediction
if __name__ == '__main__':
st.title('Fake News Classification app ')
st.subheader("Input the News content below")
sentence = st.text_area("Enter your news content here", "",height=200)
predict_btt = st.button("predict")
if predict_btt:
prediction_class=fake_news(sentence)
print(prediction_class)
if prediction_class == [0]:
st.success('Reliable')
if prediction_class == [1]:
st.warning('Unreliable')