Skip to content

nithish2409/Fake-News-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Powered Fake News Detection System

An end-to-end, high-performance web platform that evaluates the credibility of news articles. The system uses an Ensemble Classifier combining a fast keyword-based Linear SVM (baseline) and a state-of-the-art RoBERTa Transformer (deep learning) to perform real-time predictions. It includes an interactive dashboard featuring credibility visualization, highlighted keywords, reasoning insights, and automatic article scraping.


🌟 Key Features

  • Hybrid Model Ensemble: Combines classic statistical ML (Linear SVM + TF-IDF) with deep context-aware NLP (RoBERTa Sequence Classifier).
  • Reasoning & Explanation: Shows highlighted keywords and lists reasoning explanations dynamically.
  • Automatic Article Scraping: Paste a news URL to fetch the article body automatically using newspaper3k.
  • Visual Credibility Dashboard: Built with React, Tailwind CSS, TypeScript, and Recharts horizontal charts.
  • Conflict Detection: Alerts users if the keyword model and the transformer model disagree.

📂 Repository Structure

Fake-News-Detection/
├── backend/                  # FastAPI Web server & model training scripts
│   ├── main.py               # REST API entrypoint
│   ├── model_loader.py       # Prediction ensemble manager
│   ├── scraper.py            # Article web crawler (newspaper3k)
│   ├── train_svm.py          # Linear SVM training script
│   ├── train_roberta.py      # RoBERTa fine-tuning script
│   └── requirements.txt      # Python dependencies
├── data/                     # Data processing utilities
│   ├── build_combined_dataset.py # Merges & balances Kaggle, ISOT, LIAR, & FakeNewsNet
│   └── liar_dataset/         # Benchmark datasets
├── frontend/                 # React SPA Dashboard (Vite + TS + Tailwind)
│   ├── src/                  # React source files (components, charts, API)
│   └── package.json          # Node dependencies
├── models/                   # Model weight storage (ignored from git commit)
└── fake-news-detector.ipynb  # Jupyter Notebook for prototyping

🚀 Setup & Installation

1. Prerequisites

Ensure you have the following installed:


2. Backend Setup

  1. Open a terminal and navigate to the backend directory:
    cd backend
  2. Create and activate a Python virtual environment:
    python -m venv venv
    # On Windows (PowerShell):
    .\venv\Scripts\Activate.ps1
    # On macOS/Linux:
    source venv/bin/activate
  3. Install the dependencies:
    pip install -r requirements.txt
  4. Start the FastAPI development server:
    uvicorn main:app --reload --port 8000
    The server will start at http://localhost:8000.

3. Frontend Setup

  1. Open a new terminal and navigate to the frontend directory:
    cd frontend
  2. Install npm packages:
    npm install
  3. Start the Vite development server:
    npm run dev
    The frontend dashboard will be available at http://localhost:5173.

📊 Training the Models (Optional)

If you wish to re-train the classification models from scratch:

  1. Build the dataset: Make sure you download the raw Kaggle datasets (Fake.csv / True.csv or isot_fake.csv / isot_real.csv) into the data/ folder, then run:
    python data/build_combined_dataset.py
  2. Train the SVM Baseline:
    python backend/train_svm.py
  3. Train the RoBERTa Transformer:
    python backend/train_roberta.py
    Note: Training RoBERTa is GPU-intensive and is recommended on a CUDA-compatible GPU (e.g. RTX 4060).

About

An end-to-end credibility analysis platform that uses an ensemble of classic Machine Learning (Linear SVM) and Deep Learning (RoBERTa Transformer) to detect fake news in real-time. Features a React dashboard, automatic URL article scraping, model comparison views, and contextual reasoning insights.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors