Skip to content

πŸ” Fake News Detection with BERT & Traditional ML Real-time fake news classification using BERT Transformers and traditional machine learning models. Includes URL-based article scraping, language detection, multilingual support, and Streamlit-based UI with confidence visualization.

License

Notifications You must be signed in to change notification settings

PankajMahanto/FakeNewsDetection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“° Fake News Detector (BERT + Streamlit)

A real-time fake news detection web application built using a fine-tuned BERT model with an elegant Streamlit interface. The system supports manual input and URL-based article analysis with multilingual support and clean visual feedback.

The Fake News Detection Web Application is a locally deployed tool that uses traditional machine learning algorithms like Logistic Regression and Random Forest to classify news articles as real or fake. It offers a simple web interface for real-time predictions, aiming to combat misinformation and promote media awareness.


🧠 Model Architecture: BERT-Powered Fake News Detection System

Working

πŸ§ͺ Screenshots

Home

Manual text

Results

URL

Results_url

πŸ” Features

  • 🧠 BERT-based classification of news articles as Fake or Real
  • 🌐 URL scraping using newspaper3k and auto language detection
  • ✨ Real-time feedback with model-wise comparison: Logistic Regression, Random Forest, SVM, Naive Bayes, and BERT
  • πŸ“Š Dynamic confidence bars (green = Real, red = Fake)
  • 🌍 Auto-translation for non-English news using Google Translate
  • πŸ“± Streamlit-powered UI with dark mode and modern UX

πŸ› οΈ Tech Stack

  • Frontend: Streamlit
  • ML Models:
    • Logistic Regression
    • Random Forest
    • Naive Bayes
    • SVM
    • BERT (transformers by HuggingFace)
  • Vectorizers: TfidfVectorizer, CountVectorizer
  • Tools: joblib, torch, langdetect, deep-translator, newspaper3k

πŸš€ How to Run

1. Clone the Repository

git clone https://github.com/PankajMahanto/FakeNewsDetection.git
cd FakeNewsDetection

2. Create a Virtual Environment (Optional but Recommended)

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Requirements

bash
pip install -r requirements.txt

4. Run the App

bash
streamlit run app.py

πŸ“ Project Structure

bash

|β€”β€” .gitattributes
|β€”β€” app.ipynb
|β€”β€” app.py
|β€”β€” app_rf.ipynb
|β€”β€” bert_fakenews
|    |β€”β€” config.json
|    |β€”β€” model.safetensors
|    |β€”β€” special_tokens_map.json
|    |β€”β€” tokenizer.json
|    |β€”β€” tokenizer_config.json
|    |β€”β€” vocab.txt
|β€”β€” bert_fakenews_vs.ipynb
|β€”β€” copy-app.py
|β€”β€” Datasets
|    |β€”β€” Fake.csv
|    |β€”β€” True.csv
|β€”β€” Datasets.zip
|β€”β€” lr_model.jb
|β€”β€” model.jb
|β€”β€” model_load.ipynb
|β€”β€” nb_model.jb
|β€”β€” r.md
|β€”β€” requirements.txt
|β€”β€” rf_model.jb
|β€”β€” rf_model.zip
|β€”β€” svm_model.jb
|β€”β€” tfidf_vectorizer.jb
|β€”β€” train_bert.py
|β€”β€” train_bert_news.ipynb
|β€”β€” Train_nb.ipynb
|β€”β€” train_svm.ipynb
|β€”β€” vectorizer.jb
|β€”β€” vectorizer_nb.jb
|β€”β€” vectorizer_rf.jb
|β€”β€” visualization_of_project.ipynb

Code Details

Tested Platform

  • software
    OS: Debian unstable (May 2021), Ubuntu LTS
    Python: 3.8.5 (anaconda)
    PyTorch: 1.7.1, 1.8.1
    
  • hardware
    CPU: Intel Xeon 6226R / Normal CPU work
    GPU: No Needed
    RAM: At least 8GB
    

πŸ‘€ Author

Made with ❀️ by Pankaj Mahanta

About

πŸ” Fake News Detection with BERT & Traditional ML Real-time fake news classification using BERT Transformers and traditional machine learning models. Includes URL-based article scraping, language detection, multilingual support, and Streamlit-based UI with confidence visualization.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published