ibrahimnomad commited on
Commit
8ec5b9a
1 Parent(s): eb00392

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. app.py +43 -0
  3. fake_or_real_news.csv +3 -0
  4. requirements.txt +4 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ fake_or_real_news.csv filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ from sklearn.feature_extraction.text import CountVectorizer
4
+ from sklearn.model_selection import train_test_split
5
+ from sklearn.naive_bayes import MultinomialNB
6
+ import streamlit as st
7
+
8
+ # Set page title and icon
9
+ st.set_page_config(page_title='Fake News Detection', page_icon=":postal_horn:")
10
+
11
+ # Load the dataset
12
+ df = pd.read_csv("fake_or_real_news.csv")
13
+
14
+ # Train the model
15
+ x = np.array(df["title"])
16
+ y = np.array(df["label"])
17
+ cv = CountVectorizer()
18
+ x = cv.fit_transform(x)
19
+
20
+ xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.2, random_state=42)
21
+ model = MultinomialNB()
22
+ model.fit(xtrain, ytrain)
23
+
24
+
25
+ st.title('Fake News Detection :postal_horn:')
26
+
27
+ # Display an image
28
+ st.image("https://upload.wikimedia.org/wikipedia/commons/f/f7/The_fin_de_siècle_newspaper_proprietor_%28cropped%29.jpg")
29
+
30
+ # Input field for user to enter news headline
31
+ default_example = "Alians decided to my America after Russia Exploded"
32
+ news_headline = st.text_input("Enter a news headline:", default_example)
33
+
34
+ if st.button("Check"):
35
+ # Make prediction
36
+ df_input = cv.transform([news_headline]).toarray()
37
+ prediction = model.predict(df_input)
38
+
39
+ # Display prediction result
40
+ if prediction[0] == 'FAKE':
41
+ st.error("This news headline is likely FAKE.")
42
+ else:
43
+ st.success("This news headline is likely REAL.")
fake_or_real_news.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb7fa746dd7148b63b0a10e47b329f4b4825afc85b206d3fea18ecfce28ee731
3
+ size 30696129
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ scikit-learn
4
+ streamlit