Skip to content

About

Fake News Detection System using NLP, TF-IDF Vectorization, and Machine Learning to classify news articles as Fake or Real with high accuracy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📰 Fake News Detection System

Classifying news articles as Fake or Real with NLP, TF-IDF and Logistic Regression

Python scikit-learn NLTK NLP Dataset


📌 Overview

Misinformation spreads faster than corrections. This project trains a text classifier on 44,000+ labelled news articles to decide whether a new article is FAKE or REAL, and reports how confident it is.

Articles are cleaned with an NLP pipeline, turned into TF-IDF vectors, and classified with Logistic Regression. After training, you can paste any article into the terminal and get an instant prediction.

✨ Features

  • 🧹 Text cleaning: lowercase, strip URLs, HTML, punctuation, digits and stopwords (NLTK)
  • 🔢 TF-IDF vectorisation of article text
  • 🤖 Logistic Regression classifier
  • 📊 Accuracy, precision, recall, F1 and a confusion matrix
  • 📏 Word-count comparison of fake vs real articles
  • ⌨️ Interactive mode: paste your own article and get FAKE / REAL + confidence %

🔄 Pipeline

flowchart LR
    A[Fake.csv + True.csv] --> B[Label 0 = Fake, 1 = Real]
    B --> C[Clean text]
    C --> D[Train/test split 75/25]
    D --> E[TF-IDF]
    E --> F[Logistic Regression]
    F --> G[Metrics + confusion matrix]
    F --> H[Predict custom article]
Loading

📂 Project Structure

FakeNews_Detection/
├── data/
│   ├── Fake.csv          # ~23,000 fake articles
│   └── True.csv          # ~21,000 real articles
├── outputs/              # Generated charts
├── src/
│   └── main.py           # Full pipeline + interactive prediction
├── requirements.txt
└── README.md

🚀 Getting Started

git clone https://github.com/Gaganajain/FakeNews_Detection.git
cd FakeNews_Detection
pip install -r requirements.txt
cd src
python main.py

After training, the program asks for an article:

Enter News Article:
NASA confirms the next crewed mission to the Moon is scheduled for ...

Prediction: REAL NEWS (97.85% confidence)

📸 Results

Confusion matrix

🛠️ Tech Stack

Area Tools
Language Python
NLP NLTK stopwords, regex cleaning, TF-IDF
ML scikit-learn Logistic Regression
Visualisation Matplotlib, Seaborn

🔮 Future Improvements

  • Compare with Naive Bayes, PassiveAggressive and a fine-tuned BERT model
  • Save the trained model with joblib and serve it through a Streamlit web app
  • Use the article title and subject as extra features

👩‍💻 Author

Gagana Jain A · GitHub

⭐ If you found this useful, consider giving the repo a star!

About

Fake News Detection System using NLP, TF-IDF Vectorization, and Machine Learning to classify news articles as Fake or Real with high accuracy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages