From c8b7de79e6339633925677dabbe40d839867540f Mon Sep 17 00:00:00 2001 From: Panchadip <165953910+Panchadip-128@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:41:43 +0530 Subject: [PATCH 1/3] Add files via upload Issue #1783 Created a Fake news Detection AI Model, using machine learning algorithms like Logistic Regression, Decision Tree, Gradient Boosting, and Random Forest. The dataset consists of real and fake news articles, and you've applied preprocessing, feature extraction using TF-IDF, and trained several models --- ...ews Detection using machine learning.ipynb | 1759 +++++++++++++++++ README (1).md | 94 + 2 files changed, 1853 insertions(+) create mode 100644 Fake News Detection using machine learning.ipynb create mode 100644 README (1).md diff --git a/Fake News Detection using machine learning.ipynb b/Fake News Detection using machine learning.ipynb new file mode 100644 index 000000000..36db61e21 --- /dev/null +++ b/Fake News Detection using machine learning.ipynb @@ -0,0 +1,1759 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "68a0802a", + "metadata": {}, + "source": [ + "# Fake News Detector" + ] + }, + { + "cell_type": "markdown", + "id": "34865a8e", + "metadata": {}, + "source": [ + "## Installing Necessary Libraries" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "2a23a115", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "import seaborn as sns\n", + "import string\n", + "import re\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.metrics import accuracy_score\n", + "from sklearn.metrics import classification_report" + ] + }, + { + "cell_type": "markdown", + "id": "793b507f", + "metadata": {}, + "source": [ + "## Loading the data" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "efb35954", + "metadata": {}, + "outputs": [], + "source": [ + "data_fake=pd.read_csv('Fake.csv')\n", + "data_true=pd.read_csv('True.csv')" + ] + }, + { + "cell_type": "markdown", + "id": "607c382f", + "metadata": {}, + "source": [ + "### Data Preview " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "a9a4cc2b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
titletextsubjectdate
0Donald Trump Sends Out Embarrassing New Year’...Donald Trump just couldn t wish all Americans ...NewsDecember 31, 2017
1Drunk Bragging Trump Staffer Started Russian ...House Intelligence Committee Chairman Devin Nu...NewsDecember 31, 2017
2Sheriff David Clarke Becomes An Internet Joke...On Friday, it was revealed that former Milwauk...NewsDecember 30, 2017
3Trump Is So Obsessed He Even Has Obama’s Name...On Christmas day, Donald Trump announced that ...NewsDecember 29, 2017
4Pope Francis Just Called Out Donald Trump Dur...Pope Francis used his annual Christmas Day mes...NewsDecember 25, 2017
\n", + "
" + ], + "text/plain": [ + " title \\\n", + "0 Donald Trump Sends Out Embarrassing New Year’... \n", + "1 Drunk Bragging Trump Staffer Started Russian ... \n", + "2 Sheriff David Clarke Becomes An Internet Joke... \n", + "3 Trump Is So Obsessed He Even Has Obama’s Name... \n", + "4 Pope Francis Just Called Out Donald Trump Dur... \n", + "\n", + " text subject \\\n", + "0 Donald Trump just couldn t wish all Americans ... News \n", + "1 House Intelligence Committee Chairman Devin Nu... News \n", + "2 On Friday, it was revealed that former Milwauk... News \n", + "3 On Christmas day, Donald Trump announced that ... News \n", + "4 Pope Francis used his annual Christmas Day mes... News \n", + "\n", + " date \n", + "0 December 31, 2017 \n", + "1 December 31, 2017 \n", + "2 December 30, 2017 \n", + "3 December 29, 2017 \n", + "4 December 25, 2017 " + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_fake.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "a6203eaa", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
titletextsubjectdate
21412'Fully committed' NATO backs new U.S. approach...BRUSSELS (Reuters) - NATO allies on Tuesday we...worldnewsAugust 22, 2017
21413LexisNexis withdrew two products from Chinese ...LONDON (Reuters) - LexisNexis, a provider of l...worldnewsAugust 22, 2017
21414Minsk cultural hub becomes haven from authoritiesMINSK (Reuters) - In the shadow of disused Sov...worldnewsAugust 22, 2017
21415Vatican upbeat on possibility of Pope Francis ...MOSCOW (Reuters) - Vatican Secretary of State ...worldnewsAugust 22, 2017
21416Indonesia to buy $1.14 billion worth of Russia...JAKARTA (Reuters) - Indonesia will buy 11 Sukh...worldnewsAugust 22, 2017
\n", + "
" + ], + "text/plain": [ + " title \\\n", + "21412 'Fully committed' NATO backs new U.S. approach... \n", + "21413 LexisNexis withdrew two products from Chinese ... \n", + "21414 Minsk cultural hub becomes haven from authorities \n", + "21415 Vatican upbeat on possibility of Pope Francis ... \n", + "21416 Indonesia to buy $1.14 billion worth of Russia... \n", + "\n", + " text subject \\\n", + "21412 BRUSSELS (Reuters) - NATO allies on Tuesday we... worldnews \n", + "21413 LONDON (Reuters) - LexisNexis, a provider of l... worldnews \n", + "21414 MINSK (Reuters) - In the shadow of disused Sov... worldnews \n", + "21415 MOSCOW (Reuters) - Vatican Secretary of State ... worldnews \n", + "21416 JAKARTA (Reuters) - Indonesia will buy 11 Sukh... worldnews \n", + "\n", + " date \n", + "21412 August 22, 2017 \n", + "21413 August 22, 2017 \n", + "21414 August 22, 2017 \n", + "21415 August 22, 2017 \n", + "21416 August 22, 2017 " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_true.tail()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "af3041d0", + "metadata": {}, + "outputs": [], + "source": [ + "data_fake[\"class\"]=0\n", + "data_true['class']=1" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "30fe3918", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "((23481, 5), (21417, 5))" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_fake.shape, data_true.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "a2332b8d", + "metadata": {}, + "outputs": [], + "source": [ + "data_fake_manual_testing = data_fake.tail(10)\n", + "for i in range(23480,23470,-1):\n", + " data_fake.drop([i],axis = 0, inplace = True)\n", + "\n", + " \n", + "data_true_manual_testing = data_true.tail(10)\n", + "for i in range(21416,21406,-1):\n", + " data_true.drop([i],axis = 0, inplace = True)\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "004f6d60", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "((23471, 5), (21407, 5))" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_fake.shape, data_true.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "cbdb2b38", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\Dell\\AppData\\Local\\Temp\\ipykernel_1640\\1676563180.py:1: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " data_fake_manual_testing['class']=0\n", + "C:\\Users\\Dell\\AppData\\Local\\Temp\\ipykernel_1640\\1676563180.py:2: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " data_true_manual_testing['class']=1\n" + ] + } + ], + "source": [ + "data_fake_manual_testing['class']=0\n", + "data_true_manual_testing['class']=1" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "15140120", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
titletextsubjectdateclass
23471Seven Iranians freed in the prisoner swap have...21st Century Wire says This week, the historic...Middle-eastJanuary 20, 20160
23472#Hashtag Hell & The Fake LeftBy Dady Chery and Gilbert MercierAll writers ...Middle-eastJanuary 19, 20160
23473Astroturfing: Journalist Reveals Brainwashing ...Vic Bishop Waking TimesOur reality is carefull...Middle-eastJanuary 19, 20160
23474The New American Century: An Era of FraudPaul Craig RobertsIn the last years of the 20t...Middle-eastJanuary 19, 20160
23475Hillary Clinton: ‘Israel First’ (and no peace ...Robert Fantina CounterpunchAlthough the United...Middle-eastJanuary 18, 20160
23476McPain: John McCain Furious That Iran Treated ...21st Century Wire says As 21WIRE reported earl...Middle-eastJanuary 16, 20160
23477JUSTICE? Yahoo Settles E-mail Privacy Class-ac...21st Century Wire says It s a familiar theme. ...Middle-eastJanuary 16, 20160
23478Sunnistan: US and Allied ‘Safe Zone’ Plan to T...Patrick Henningsen 21st Century WireRemember ...Middle-eastJanuary 15, 20160
23479How to Blow $700 Million: Al Jazeera America F...21st Century Wire says Al Jazeera America will...Middle-eastJanuary 14, 20160
2348010 U.S. Navy Sailors Held by Iranian Military ...21st Century Wire says As 21WIRE predicted in ...Middle-eastJanuary 12, 20160
\n", + "
" + ], + "text/plain": [ + " title \\\n", + "23471 Seven Iranians freed in the prisoner swap have... \n", + "23472 #Hashtag Hell & The Fake Left \n", + "23473 Astroturfing: Journalist Reveals Brainwashing ... \n", + "23474 The New American Century: An Era of Fraud \n", + "23475 Hillary Clinton: ‘Israel First’ (and no peace ... \n", + "23476 McPain: John McCain Furious That Iran Treated ... \n", + "23477 JUSTICE? Yahoo Settles E-mail Privacy Class-ac... \n", + "23478 Sunnistan: US and Allied ‘Safe Zone’ Plan to T... \n", + "23479 How to Blow $700 Million: Al Jazeera America F... \n", + "23480 10 U.S. Navy Sailors Held by Iranian Military ... \n", + "\n", + " text subject \\\n", + "23471 21st Century Wire says This week, the historic... Middle-east \n", + "23472 By Dady Chery and Gilbert MercierAll writers ... Middle-east \n", + "23473 Vic Bishop Waking TimesOur reality is carefull... Middle-east \n", + "23474 Paul Craig RobertsIn the last years of the 20t... Middle-east \n", + "23475 Robert Fantina CounterpunchAlthough the United... Middle-east \n", + "23476 21st Century Wire says As 21WIRE reported earl... Middle-east \n", + "23477 21st Century Wire says It s a familiar theme. ... Middle-east \n", + "23478 Patrick Henningsen 21st Century WireRemember ... Middle-east \n", + "23479 21st Century Wire says Al Jazeera America will... Middle-east \n", + "23480 21st Century Wire says As 21WIRE predicted in ... Middle-east \n", + "\n", + " date class \n", + "23471 January 20, 2016 0 \n", + "23472 January 19, 2016 0 \n", + "23473 January 19, 2016 0 \n", + "23474 January 19, 2016 0 \n", + "23475 January 18, 2016 0 \n", + "23476 January 16, 2016 0 \n", + "23477 January 16, 2016 0 \n", + "23478 January 15, 2016 0 \n", + "23479 January 14, 2016 0 \n", + "23480 January 12, 2016 0 " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_fake_manual_testing.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ae7531db", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
titletextsubjectdateclass
21407Mata Pires, owner of embattled Brazil builder ...SAO PAULO (Reuters) - Cesar Mata Pires, the ow...worldnewsAugust 22, 20171
21408U.S., North Korea clash at U.N. forum over nuc...GENEVA (Reuters) - North Korea and the United ...worldnewsAugust 22, 20171
21409U.S., North Korea clash at U.N. arms forum on ...GENEVA (Reuters) - North Korea and the United ...worldnewsAugust 22, 20171
21410Headless torso could belong to submarine journ...COPENHAGEN (Reuters) - Danish police said on T...worldnewsAugust 22, 20171
21411North Korea shipments to Syria chemical arms a...UNITED NATIONS (Reuters) - Two North Korean sh...worldnewsAugust 21, 20171
21412'Fully committed' NATO backs new U.S. approach...BRUSSELS (Reuters) - NATO allies on Tuesday we...worldnewsAugust 22, 20171
21413LexisNexis withdrew two products from Chinese ...LONDON (Reuters) - LexisNexis, a provider of l...worldnewsAugust 22, 20171
21414Minsk cultural hub becomes haven from authoritiesMINSK (Reuters) - In the shadow of disused Sov...worldnewsAugust 22, 20171
21415Vatican upbeat on possibility of Pope Francis ...MOSCOW (Reuters) - Vatican Secretary of State ...worldnewsAugust 22, 20171
21416Indonesia to buy $1.14 billion worth of Russia...JAKARTA (Reuters) - Indonesia will buy 11 Sukh...worldnewsAugust 22, 20171
\n", + "
" + ], + "text/plain": [ + " title \\\n", + "21407 Mata Pires, owner of embattled Brazil builder ... \n", + "21408 U.S., North Korea clash at U.N. forum over nuc... \n", + "21409 U.S., North Korea clash at U.N. arms forum on ... \n", + "21410 Headless torso could belong to submarine journ... \n", + "21411 North Korea shipments to Syria chemical arms a... \n", + "21412 'Fully committed' NATO backs new U.S. approach... \n", + "21413 LexisNexis withdrew two products from Chinese ... \n", + "21414 Minsk cultural hub becomes haven from authorities \n", + "21415 Vatican upbeat on possibility of Pope Francis ... \n", + "21416 Indonesia to buy $1.14 billion worth of Russia... \n", + "\n", + " text subject \\\n", + "21407 SAO PAULO (Reuters) - Cesar Mata Pires, the ow... worldnews \n", + "21408 GENEVA (Reuters) - North Korea and the United ... worldnews \n", + "21409 GENEVA (Reuters) - North Korea and the United ... worldnews \n", + "21410 COPENHAGEN (Reuters) - Danish police said on T... worldnews \n", + "21411 UNITED NATIONS (Reuters) - Two North Korean sh... worldnews \n", + "21412 BRUSSELS (Reuters) - NATO allies on Tuesday we... worldnews \n", + "21413 LONDON (Reuters) - LexisNexis, a provider of l... worldnews \n", + "21414 MINSK (Reuters) - In the shadow of disused Sov... worldnews \n", + "21415 MOSCOW (Reuters) - Vatican Secretary of State ... worldnews \n", + "21416 JAKARTA (Reuters) - Indonesia will buy 11 Sukh... worldnews \n", + "\n", + " date class \n", + "21407 August 22, 2017 1 \n", + "21408 August 22, 2017 1 \n", + "21409 August 22, 2017 1 \n", + "21410 August 22, 2017 1 \n", + "21411 August 21, 2017 1 \n", + "21412 August 22, 2017 1 \n", + "21413 August 22, 2017 1 \n", + "21414 August 22, 2017 1 \n", + "21415 August 22, 2017 1 \n", + "21416 August 22, 2017 1 " + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_true_manual_testing.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "39dfcd6f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
titletextsubjectdateclass
0Donald Trump Sends Out Embarrassing New Year’...Donald Trump just couldn t wish all Americans ...NewsDecember 31, 20170
1Drunk Bragging Trump Staffer Started Russian ...House Intelligence Committee Chairman Devin Nu...NewsDecember 31, 20170
2Sheriff David Clarke Becomes An Internet Joke...On Friday, it was revealed that former Milwauk...NewsDecember 30, 20170
3Trump Is So Obsessed He Even Has Obama’s Name...On Christmas day, Donald Trump announced that ...NewsDecember 29, 20170
4Pope Francis Just Called Out Donald Trump Dur...Pope Francis used his annual Christmas Day mes...NewsDecember 25, 20170
5Racist Alabama Cops Brutalize Black Boy While...The number of cases of cops brutalizing and ki...NewsDecember 25, 20170
6Fresh Off The Golf Course, Trump Lashes Out A...Donald Trump spent a good portion of his day a...NewsDecember 23, 20170
7Trump Said Some INSANELY Racist Stuff Inside ...In the wake of yet another court decision that...NewsDecember 23, 20170
8Former CIA Director Slams Trump Over UN Bully...Many people have raised the alarm regarding th...NewsDecember 22, 20170
9WATCH: Brand-New Pro-Trump Ad Features So Muc...Just when you might have thought we d get a br...NewsDecember 21, 20170
\n", + "
" + ], + "text/plain": [ + " title \\\n", + "0 Donald Trump Sends Out Embarrassing New Year’... \n", + "1 Drunk Bragging Trump Staffer Started Russian ... \n", + "2 Sheriff David Clarke Becomes An Internet Joke... \n", + "3 Trump Is So Obsessed He Even Has Obama’s Name... \n", + "4 Pope Francis Just Called Out Donald Trump Dur... \n", + "5 Racist Alabama Cops Brutalize Black Boy While... \n", + "6 Fresh Off The Golf Course, Trump Lashes Out A... \n", + "7 Trump Said Some INSANELY Racist Stuff Inside ... \n", + "8 Former CIA Director Slams Trump Over UN Bully... \n", + "9 WATCH: Brand-New Pro-Trump Ad Features So Muc... \n", + "\n", + " text subject \\\n", + "0 Donald Trump just couldn t wish all Americans ... News \n", + "1 House Intelligence Committee Chairman Devin Nu... News \n", + "2 On Friday, it was revealed that former Milwauk... News \n", + "3 On Christmas day, Donald Trump announced that ... News \n", + "4 Pope Francis used his annual Christmas Day mes... News \n", + "5 The number of cases of cops brutalizing and ki... News \n", + "6 Donald Trump spent a good portion of his day a... News \n", + "7 In the wake of yet another court decision that... News \n", + "8 Many people have raised the alarm regarding th... News \n", + "9 Just when you might have thought we d get a br... News \n", + "\n", + " date class \n", + "0 December 31, 2017 0 \n", + "1 December 31, 2017 0 \n", + "2 December 30, 2017 0 \n", + "3 December 29, 2017 0 \n", + "4 December 25, 2017 0 \n", + "5 December 25, 2017 0 \n", + "6 December 23, 2017 0 \n", + "7 December 23, 2017 0 \n", + "8 December 22, 2017 0 \n", + "9 December 21, 2017 0 " + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_merge=pd.concat([data_fake, data_true], axis = 0)\n", + "data_merge.head(10)" + ] + }, + { + "cell_type": "markdown", + "id": "ea1cd410", + "metadata": {}, + "source": [ + "#### \"title\", \"subject\" and \"date\" columns is not required for detecting the fake news, so I am going to drop the columns." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "097c2870", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['title', 'text', 'subject', 'date', 'class'], dtype='object')" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_merge.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "3adccb7e", + "metadata": {}, + "outputs": [], + "source": [ + "data=data_merge.drop(['title','subject','date'], axis = 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "8fb4c981", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "text 0\n", + "class 0\n", + "dtype: int64" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#count of missing values\n", + "data.isnull().sum() " + ] + }, + { + "cell_type": "markdown", + "id": "0cfe0118", + "metadata": {}, + "source": [ + "#### Randomly shuffling the dataframe " + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fe609699", + "metadata": {}, + "outputs": [], + "source": [ + "data = data.sample(frac = 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "c9e879eb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
textclass
1147As the divisions in the nation bubble over, it...0
7953Six people are dead after a white, domestic te...0
9026WASHINGTON (Reuters) - Democrat Hillary Clinto...1
16943ATHENS (Reuters) - Greek police said they arre...1
5809WASHINGTON/LOS ANGELES (Reuters) - U.S. Presid...1
\n", + "
" + ], + "text/plain": [ + " text class\n", + "1147 As the divisions in the nation bubble over, it... 0\n", + "7953 Six people are dead after a white, domestic te... 0\n", + "9026 WASHINGTON (Reuters) - Democrat Hillary Clinto... 1\n", + "16943 ATHENS (Reuters) - Greek police said they arre... 1\n", + "5809 WASHINGTON/LOS ANGELES (Reuters) - U.S. Presid... 1" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "33ddd95b", + "metadata": {}, + "outputs": [], + "source": [ + "data.reset_index(inplace = True)\n", + "data.drop(['index'], axis = 1, inplace = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "c70930a1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['text', 'class'], dtype='object')" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "cd7a7a95", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
textclass
0As the divisions in the nation bubble over, it...0
1Six people are dead after a white, domestic te...0
2WASHINGTON (Reuters) - Democrat Hillary Clinto...1
3ATHENS (Reuters) - Greek police said they arre...1
4WASHINGTON/LOS ANGELES (Reuters) - U.S. Presid...1
\n", + "
" + ], + "text/plain": [ + " text class\n", + "0 As the divisions in the nation bubble over, it... 0\n", + "1 Six people are dead after a white, domestic te... 0\n", + "2 WASHINGTON (Reuters) - Democrat Hillary Clinto... 1\n", + "3 ATHENS (Reuters) - Greek police said they arre... 1\n", + "4 WASHINGTON/LOS ANGELES (Reuters) - U.S. Presid... 1" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.head()" + ] + }, + { + "cell_type": "markdown", + "id": "20157149", + "metadata": {}, + "source": [ + "## Preprocessing Text" + ] + }, + { + "cell_type": "markdown", + "id": "56c82e01", + "metadata": {}, + "source": [ + "#### Creating a function to convert the text in lowercase, remove the extra space, special chr., ulr and links." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "453dfdbf", + "metadata": {}, + "outputs": [], + "source": [ + "def wordopt(text):\n", + " text = text.lower()\n", + " text = re.sub('\\[.*?\\]','',text)\n", + " text = re.sub(\"\\\\W\",\" \",text)\n", + " text = re.sub('https?://\\S+|www\\.\\S+','',text)\n", + " text = re.sub('<.*?>+',b'',text)\n", + " text = re.sub('[%s]' % re.escape(string.punctuation),'',text)\n", + " text = re.sub('\\w*\\d\\w*','',text)\n", + " return text" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "337d9a50", + "metadata": {}, + "outputs": [], + "source": [ + "data['text'] = data['text'].apply(wordopt)" + ] + }, + { + "cell_type": "markdown", + "id": "46a11e07", + "metadata": {}, + "source": [ + "#### Defining dependent and independent variable as x and y" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "39bf4b30", + "metadata": {}, + "outputs": [], + "source": [ + "x = data['text']\n", + "y = data['class']" + ] + }, + { + "cell_type": "markdown", + "id": "3a9aac19", + "metadata": {}, + "source": [ + "## Training the model" + ] + }, + { + "cell_type": "markdown", + "id": "415c3c72", + "metadata": {}, + "source": [ + "#### Splitting the dataset into training set and testing set. " + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "645dd4c8", + "metadata": {}, + "outputs": [], + "source": [ + "x_train, x_test, y_train, y_test = train_test_split(x,y,test_size = 0.25)" + ] + }, + { + "cell_type": "markdown", + "id": "b3169fde", + "metadata": {}, + "source": [ + "### Extracting Features from the Text" + ] + }, + { + "cell_type": "markdown", + "id": "97ddd784", + "metadata": {}, + "source": [ + "#### Convert text to vectors" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "554bda26", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.feature_extraction.text import TfidfVectorizer\n", + "\n", + "vectorization = TfidfVectorizer()\n", + "xv_train = vectorization.fit_transform(x_train)\n", + "xv_test = vectorization.transform(x_test)" + ] + }, + { + "cell_type": "markdown", + "id": "96cfbfc1", + "metadata": {}, + "source": [ + "## Logistic Regression" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "7d78b666", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.linear_model import LogisticRegression" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "2580b926", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "LogisticRegression()" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "LR = LogisticRegression()\n", + "LR.fit(xv_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "42070f76", + "metadata": {}, + "outputs": [], + "source": [ + "pred_lr = LR.predict(xv_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "0f671957", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9877896613190731" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "LR.score(xv_test, y_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "e654e1f0", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " precision recall f1-score support\n", + "\n", + " 0 0.99 0.99 0.99 5834\n", + " 1 0.99 0.99 0.99 5386\n", + "\n", + " accuracy 0.99 11220\n", + " macro avg 0.99 0.99 0.99 11220\n", + "weighted avg 0.99 0.99 0.99 11220\n", + "\n" + ] + } + ], + "source": [ + "print (classification_report(y_test, pred_lr))" + ] + }, + { + "cell_type": "markdown", + "id": "cc114e19", + "metadata": {}, + "source": [ + "## Decision Tree Classifier" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "fe6e3389", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "DecisionTreeClassifier()" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.tree import DecisionTreeClassifier\n", + "\n", + "DT = DecisionTreeClassifier()\n", + "DT.fit(xv_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "b4bbeaa5", + "metadata": {}, + "outputs": [], + "source": [ + "pred_dt = DT.predict(xv_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "442fa652", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9952762923351158" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DT.score(xv_test, y_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "6fa1ecbf", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " precision recall f1-score support\n", + "\n", + " 0 0.99 0.99 0.99 5834\n", + " 1 0.99 0.99 0.99 5386\n", + "\n", + " accuracy 0.99 11220\n", + " macro avg 0.99 0.99 0.99 11220\n", + "weighted avg 0.99 0.99 0.99 11220\n", + "\n" + ] + } + ], + "source": [ + "print (classification_report(y_test, pred_lr))" + ] + }, + { + "cell_type": "markdown", + "id": "50e62d57", + "metadata": {}, + "source": [ + "## Gradient Boost Classifier" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "cc25f83e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "GradientBoostingClassifier(random_state=0)" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.ensemble import GradientBoostingClassifier\n", + "\n", + "GB = GradientBoostingClassifier(random_state = 0)\n", + "GB.fit(xv_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "9c623e70", + "metadata": {}, + "outputs": [], + "source": [ + "pred_gb = GB.predict(xv_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "d72b75ab", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9944741532976827" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "GB.score(xv_test, y_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "99d83e4a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " precision recall f1-score support\n", + "\n", + " 0 1.00 0.99 0.99 5834\n", + " 1 0.99 1.00 0.99 5386\n", + "\n", + " accuracy 0.99 11220\n", + " macro avg 0.99 0.99 0.99 11220\n", + "weighted avg 0.99 0.99 0.99 11220\n", + "\n" + ] + } + ], + "source": [ + "print(classification_report(y_test, pred_gb))" + ] + }, + { + "cell_type": "markdown", + "id": "16da9186", + "metadata": {}, + "source": [ + "## Random Forest Classifier" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "954338d0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "RandomForestClassifier(random_state=0)" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.ensemble import RandomForestClassifier\n", + "\n", + "RF = RandomForestClassifier(random_state = 0)\n", + "RF.fit(xv_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "1fb15f46", + "metadata": {}, + "outputs": [], + "source": [ + "pred_rf = RF.predict(xv_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "b86e8830", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9869875222816399" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "RF.score(xv_test, y_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "1d02b7fb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " precision recall f1-score support\n", + "\n", + " 0 0.99 0.99 0.99 5834\n", + " 1 0.99 0.98 0.99 5386\n", + "\n", + " accuracy 0.99 11220\n", + " macro avg 0.99 0.99 0.99 11220\n", + "weighted avg 0.99 0.99 0.99 11220\n", + "\n" + ] + } + ], + "source": [ + "print (classification_report(y_test, pred_rf))" + ] + }, + { + "cell_type": "markdown", + "id": "110d58d0", + "metadata": {}, + "source": [ + "## Testing the Model" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "6f8b0f43", + "metadata": {}, + "outputs": [], + "source": [ + "def output_lable(n):\n", + " if n==0:\n", + " return \"Fake News\"\n", + " elif n==1:\n", + " return \"Not A Fake News\"\n", + " \n", + "def manual_testing(news):\n", + " testing_news = {\"text\":[news]}\n", + " new_def_test = pd.DataFrame(testing_news)\n", + " new_def_test['text'] = new_def_test[\"text\"].apply(wordopt)\n", + " new_x_test = new_def_test[\"text\"]\n", + " new_xv_test = vectorization.transform(new_x_test)\n", + " pred_LR = LR.predict(new_xv_test)\n", + " pred_DT = DT.predict(new_xv_test)\n", + " pred_GB = GB.predict(new_xv_test)\n", + " pred_RF = RF.predict(new_xv_test)\n", + " \n", + " return print(\"\\n\\nLR Predicition: {} \\nDT Prediction: {} \\nGBC Prediction: {} \\nRFC Prediction:{}\".format(output_lable(pred_LR[0]),\n", + " output_lable(pred_DT[0]),\n", + " output_lable(pred_GB[0]),\n", + " output_lable(pred_RF[0])))" + ] + }, + { + "cell_type": "markdown", + "id": "1308fb1b", + "metadata": {}, + "source": [ + "### Model Testing With Manual Entry" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "cab83cc6", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Federal health officials told the AP they have not received any reports of Ebola cases at the Nevada event. A screenshot of a supposed post from the Centers for Disease Control and Prevention confirming such cases was fabricated. And there is no record of a national emergency being declared. The claims emerged after summer storm left muddy roads flooded, stranding tens of thousands of partygoers; event organizers let traffic flow out of the main road Monday afternoon. “So it was announced earlier that Burning Man was declared a national emergency because it was flooded, and so they sent in FEMA,” a woman claims in a TikTok video shared on Instagram, suggesting the development was suspicious. The AP found no record, including on federal websites and in White House announcements, of a national emergency declaration and FEMA confirmed that it was not involved in the situation. “No FEMA personnel or assets have been deployed to the Burning Man festival and there are no requests from local or state authorities for our assistance,” FEMA spokesperson Jeremy Edwards said in an email. The TikTok video, like other posts, goes on to relay baseless rumors of reported cases of Ebola, whose occasional outbreaks in humans primarily occur in Africa, at the festival. Some posts also shared an image made to appear that the CDC confirmed the supposed outbreak on X, the platform formerly known as Twitter. The purported X post from the agency reads, “Ebola outbreak confirmed at Black Rock City, NV. It is recommended that all Burning Man attendees remain in their dwellings until further notice. Current State of Emergency in progress.” But the CDC’s X account published no such post. “CDC has not received any reports of Ebola at the Burning Man Festival and has not issued any warnings or had any requests for assistance from the state and local health departments either,” agency spokesperson Scott Pauley said in an email. Reverse image searches further show that a graphic about Ebola used in the fictitious CDC post was published by the agency in 2016, but elements of it were changed. For example, the original graphic asks, “Recently in West Africa?” But the version used in the made-up X post asks, “Recently in Nevada?” Referencing more online rumors, Pauley also noted the CDC had not received reports of mpox, formerly known as monkeypox, or Marburg, a rare but severe hemorrhagic fever, in relation to Burning Man. A representative for the Burning Man Project organization also refuted the online claims. “Quite simply, the online rumors of transmissible illnesses in Black Rock City are unfounded and untrue,” Dominique Debucquoy-Dodley said in an email. The festival had been closed to vehicles after more than a half-inch (1.3 centimeters) of rain fell Sept. 1, causing flooding and foot-deep mud, as the AP reported. The annual gathering, which launched on a San Francisco beach in 1986, attracts nearly 80,000 artists, musicians and activists for a mix of wilderness camping and avant-garde performances\n", + "\n", + "\n", + "LR Predicition: Fake News \n", + "DT Prediction: Fake News \n", + "GBC Prediction: Fake News \n", + "RFC Prediction:Fake News\n" + ] + } + ], + "source": [ + "news = str(input()) \n", + "manual_testing(news)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "8b8bdbc7", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MOSCOW (Reuters) - Russia’s former ambassador to Washington, Sergei Kislyak, said on Saturday his conversations with former White House national security adviser Michael Flynn had been transparent and focused on matters of U.S.-Russia cooperation. Kislyak ended his tenure in Washington in July but remains a key figure in ongoing U.S. investigations into Moscow’s alleged meddling in the 2016 presidential election. Flynn was forced to resign in February after it became known that he had failed to disclose the content of conversations he had with Kislyak and misled U.S. Vice-President Mike Pence about their meetings. “We only spoke about the most simple things ... but the communication was completely correct, calm, absolutely transparent. In any case, there were no secrets on our side,” Kislyak said during a panel discussion on Russian television. “There are a number of issues which are important for cooperation between Russia and the United States - most of all, terrorism. And that was one of the things we discussed.” \n", + "\n", + "\n", + "LR Predicition: Not A Fake News \n", + "DT Prediction: Not A Fake News \n", + "GBC Prediction: Not A Fake News \n", + "RFC Prediction:Not A Fake News\n" + ] + } + ], + "source": [ + "news=str(input())\n", + "manual_testing(news)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64d52cc7", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/README (1).md b/README (1).md new file mode 100644 index 000000000..39f1514b7 --- /dev/null +++ b/README (1).md @@ -0,0 +1,94 @@ +# Fake News Detection Project + +Fake-News-Detection + + +The project aims to develop a machine-learning model capable of identifying and classifying any news article as fake or not. The distribution of fake news can potentially have highly adverse effects on people and culture. This project involves building and training a model to classify news as fake news or not using a diverse dataset of news articles. We have used four techniques to determine the results of the model. + +1. **Logistic Regression** +2. **Decision Tree Classifier** +3. **Gradient Boost Classifier** +4. **Random Forest Classifier** + +## Project Overview + +Fake news has become a significant issue in today's digital age, where information spreads rapidly through various online platforms. This project leverages machine learning algorithms to automatically determine the authenticity of news articles, providing a valuable tool to combat misinformation. + +## Dataset + +We have used a labelled dataset containing news articles along with their corresponding labels (true or false). The dataset is divided into two classes: +- True: Genuine news articles +- False: Fake or fabricated news articles + +## System Requirements + +Hardware : +1. 4GB RAM +2. i3 Processor +3. 500MB free space + +Software : +1. Anaconda +2. Python + +## Dependencies + +Before running the code, make sure you have the following libraries and packages installed: + +- Python 3 +- Scikit-learn +- Pandas +- Numpy +- Seaborn +- Matplotlib +- Regular Expression + +You can install these dependencies using pip: + +```bash +pip install pandas +pip install numpy +pip install matplotlib +pip install sklearn +pip install seaborn +pip install re +``` + +## Usage + +1. Clone this repository to your local machine: + +```bash +git clone https://github.com/kapilsinghnegi/Fake-News-Detection.git +``` + +2. Navigate to the project directory: + +```bash +cd fake-news-detection +``` + +3. Execute the Jupyter Notebook or Python scripts associated with each classifier to train and test the models. For example: + +```bash +python random_forest_classifier.py +``` + +4. The code will produce evaluation metrics and provide a prediction for whether the given news is true or false based on the trained model. + +## Results + +We evaluated each classifier's performance using metrics such as accuracy, precision, recall, and F1 score. The results are documented in the project files. + +## Model Deployment + +Once you are satisfied with the performance of a particular classifier, you can deploy it in a real-world application or integrate it into a larger system for automatic fake news detection. +--- + +## Project Screenshots + +#### Not a Fake News +![Not a Fake News](https://github.com/kapilsinghnegi/Fake-News-Detection/assets/118688453/3d079c46-118a-4c53-a515-43b9146001c5) + +#### Fake News +![Fake News](https://github.com/kapilsinghnegi/Fake-News-Detection/assets/118688453/2f5262f7-801d-4293-824c-13c29fb97fed) From 0ae8a001db77ada411aae29095130fb017905874 Mon Sep 17 00:00:00 2001 From: Panchadip <165953910+Panchadip-128@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:46:02 +0530 Subject: [PATCH 2/3] Add files via upload Issue #1783 solved Created a Fake News Detection system using machine learning algorithms like Logistic Regression, Decision Tree, Gradient Boosting, and Random Forest. The dataset consists of real and fake news articles, and we have applied preprocessing, feature extraction using TF-IDF, and trained several models From a6499bcde3d6e995817df336d025f5a8e552e2a5 Mon Sep 17 00:00:00 2001 From: Panchadip <165953910+Panchadip-128@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:51:05 +0530 Subject: [PATCH 3/3] README (1).md --- README (1).md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README (1).md b/README (1).md index 39f1514b7..83a2537a1 100644 --- a/README (1).md +++ b/README (1).md @@ -1,7 +1,5 @@ # Fake News Detection Project -Fake-News-Detection - The project aims to develop a machine-learning model capable of identifying and classifying any news article as fake or not. The distribution of fake news can potentially have highly adverse effects on people and culture. This project involves building and training a model to classify news as fake news or not using a diverse dataset of news articles. We have used four techniques to determine the results of the model.