{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9fad4e45", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "from sklearn.linear_model import PassiveAggressiveClassifier\n", "from sklearn.metrics import accuracy_score, confusion_matrix\n", "\n", "import seaborn as sn\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "id": "1252a3bd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(6335, 4)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Read the data\n", "df=pd.read_csv('C:\\\\DataScienceProjects\\\\FakeNewsClassifier\\\\news.csv')\n", "\n", "#Get shape\n", "df.shape" ] }, { "cell_type": "code", "execution_count": 3, "id": "1738e4c9", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Unnamed: 0 | \n", "title | \n", "text | \n", "label | \n", "
|---|---|---|---|---|
| 0 | \n", "8476 | \n", "You Can Smell Hillary’s Fear | \n", "Daniel Greenfield, a Shillman Journalism Fello... | \n", "FAKE | \n", "
| 1 | \n", "10294 | \n", "Watch The Exact Moment Paul Ryan Committed Pol... | \n", "Google Pinterest Digg Linkedin Reddit Stumbleu... | \n", "FAKE | \n", "
| 2 | \n", "3608 | \n", "Kerry to go to Paris in gesture of sympathy | \n", "U.S. Secretary of State John F. Kerry said Mon... | \n", "REAL | \n", "
| 3 | \n", "10142 | \n", "Bernie supporters on Twitter erupt in anger ag... | \n", "— Kaydee King (@KaydeeKing) November 9, 2016 T... | \n", "FAKE | \n", "
| 4 | \n", "875 | \n", "The Battle of New York: Why This Primary Matters | \n", "It's primary day in New York and front-runners... | \n", "REAL | \n", "
PassiveAggressiveClassifier(max_iter=50)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
PassiveAggressiveClassifier(max_iter=50)