Skip to content

Latest commit

Β 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“° Fake News Detection App

Python NLP Machine Learning Vectorizer Framework API Deployment Status


πŸš€ Live Demo

πŸ‘‰ https://fake-news-detector-ujjawal.streamlit.app


πŸ“Œ Problem Statement

In today’s digital world, misinformation spreads rapidly through social media and online platforms.
It becomes difficult for users to verify whether a news article is genuine or fake.

πŸ‘‰ This project aims to automatically detect fake news using Machine Learning and NLP techniques.


πŸ’‘ Solution

We built an AI-powered web application that:

  • Analyzes news text
  • Extracts content from URLs
  • Classifies news as Real or Fake
  • Provides a confidence score
  • Shows trending real-world news

🎯 Features

  • πŸ“ Text-based fake news detection
  • 🌐 URL-based article analysis
  • πŸ“Š Confidence score with progress bar
  • πŸ” Article preview for better understanding
  • πŸ”₯ Live trending news using GNews API
  • 🎨 Interactive and modern UI (Streamlit)

🧠 Tech Stack

πŸ”Ή Programming

  • Python

πŸ”Ή Machine Learning

  • Logistic Regression

πŸ”Ή NLP

  • TF-IDF Vectorization

πŸ”Ή Frontend

  • Streamlit

πŸ”Ή APIs

  • GNews API (for trending news)

πŸ”Ή Libraries Used

  • scikit-learn
  • pandas
  • numpy
  • newspaper3k
  • requests

πŸ“‚ Project Structure

fake_news_project/
β”‚
β”œβ”€β”€ app/
β”‚   └── app.py              # Streamlit application
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ Fake.csv           # Fake news dataset
β”‚   └── True.csv           # Real news dataset
β”‚
β”œβ”€β”€ model/
β”‚   β”œβ”€β”€ model.pkl          # Trained ML model
β”‚   └── vectorizer.pkl     # TF-IDF vectorizer
β”‚
β”œβ”€β”€ main.py                # Model training script
β”œβ”€β”€ requirements.txt       # Dependencies
└── README.md              # Documentation

βš™οΈ How It Works (Step-by-Step)

1️⃣ Data Collection

  • Used two datasets:
    • Fake News
    • Real News

2️⃣ Data Preprocessing

  • Converted text to lowercase
  • Removed special characters using regex
  • Cleaned noise and unwanted symbols

3️⃣ Feature Engineering

  • Applied TF-IDF Vectorizer
  • Converted text into numerical vectors

4️⃣ Model Training

  • Used Logistic Regression
  • Split dataset into training and testing
  • Achieved high accuracy (~99%)

5️⃣ Prediction Pipeline

User input β†’ Clean text β†’ Transform (TF-IDF) β†’ Model prediction

Output:

  • Real / Fake
  • Confidence score

🌐 URL Processing

  • Uses newspaper3k library
  • Extracts full article text automatically
  • Applies same ML pipeline for prediction

πŸ”₯ Trending News Feature

  • Integrated with GNews API
  • Fetches real-time headlines
  • Displays:
    • Title
    • Source
    • Link

πŸ“Š Model Performance

  • Accuracy: ~99%
  • Precision: High
  • Recall: High

πŸ‘‰ Note: High accuracy is due to dataset characteristics.


⚠️ Limitations

  • Model trained on specific dataset β†’ may not generalize fully
  • Cannot verify factual correctness (pattern-based prediction)
  • Sensitive to writing style differences

πŸš€ Future Improvements

  • Use BERT / Transformers for better understanding
  • Add explainability (why prediction is fake/real)
  • Improve UI with dashboard design
  • Add multilingual support
  • Store prediction history

▢️ Run Locally

1. Clone Repository

git clone https://github.com/your-username/fake-news-project.git
cd fake-news-project

2. Install Dependencies

pip install -r requirements.txt

3. Run App

streamlit run app/app.py

☁️ Deployment

Deployed using Streamlit Community Cloud


πŸ‘¨β€πŸ’» Author

Ujjawal Shrivastava
Aspiring Data Scientist


⭐ Conclusion

This project demonstrates how Machine Learning + NLP can be applied to solve real-world problems like fake news detection.

It showcases:

  • End-to-end ML pipeline
  • Real-time API integration
  • Interactive UI development
  • Cloud deployment

Screenshots

image image image

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages