Fake News Detection with Python (Machine-learning)
Fake news is news blogs, articles, or posts that are deliberately and verifiably incorrect with the sole aim to sway people's view of actual/true facts, activities, and claims. It's about material given as news that the promoter knows to be fake, based on manifestly inaccurate facts or comments or events that did not occur. "Fabricated material that seems to be news media content but lacks the news industry's editorial guidelines and techniques for ensuring information accuracy and trustworthiness," according to Wikipedia. Misinformation (false or misleading information) and disinformation (false or misleading information) are comparable terms (false information purposely spread to mislead people).
- Python3
- Jupyter Notebook
- Sci-kit learn
Install Sci-kit learn:
pip install -U scikit-learn
Install Jupyter notebook:
pip install notebook
Launch it with this command:
jupyter notebook
The Dataset can be downloaded here: https://www.kaggle.com/datasets/hassanamin/textdb3/download
import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
Just modify the text of the news_headline
variable. You should add a news headline to it and run the code, it will definitely predict if it is true or fake.
Happy Coding. 🥳