Skip to content
HarshXAIPublic

About

Fake news detection on social-media propagation graphs using GATv2 and the FakeNewsNet dataset.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

6 Commits

Folders and files

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

Repository files navigation

Fake News Propagation Detection using Graph Attention Networks (GAT)

A research-grade implementation for detecting and analyzing fake news propagation patterns on social media using the FakeNewsNet dataset.

🎯 Project Objectives

  • Find Key Spreaders – Identify influential users using attention weights
  • Map Full Spread – Build propagation trees for each news item
  • Build Simple, Strong Model – Efficient GAT without heavy architecture
  • Get Better Results – Combine user influence, post content, and source credibility
  • Explain Decisions – Interpret attention weights and propagation paths

πŸ“Š Dataset

FakeNewsNet: https://github.com/KaiDMML/FakeNewsNet

Components:

  • News content (source, headline, body text, images/videos)
  • Social context (user profiles, content, followers, followees)
  • User-user and user-post interaction graphs

πŸ” Pipeline

flowchart LR
    RAW["FakeNewsNet<br/>raw JSON"] --> PRE["Preprocess"]
    PRE --> G["Build propagation graph<br/>news Β· users Β· posts"]
    G --> F["Features<br/>content Β· source credibility<br/>temporal Β· echo chamber"]
    F --> GAT["GATv2 model"]
    GAT --> OUT["Fake / Real"]
    GAT --> ATT["Attention maps<br/>key spreaders"]
Loading

πŸ—οΈ Project Structure

majorProject/
β”œβ”€β”€ data/                          # Raw and processed data
β”‚   β”œβ”€β”€ raw/                       # FakeNewsNet raw JSON files
β”‚   β”œβ”€β”€ processed/                 # Cleaned and preprocessed data
β”‚   └── graphs/                    # Constructed graph structures
β”œβ”€β”€ src/                           # Source code
β”‚   β”œβ”€β”€ data/                      # Data ingestion and preprocessing
β”‚   β”œβ”€β”€ features/                  # Feature engineering
β”‚   β”œβ”€β”€ models/                    # GAT model definitions
β”‚   β”œβ”€β”€ training/                  # Training scripts
β”‚   β”œβ”€β”€ evaluation/                # Evaluation and metrics
β”‚   └── visualization/             # Attention maps and graphs
β”œβ”€β”€ notebooks/                     # Jupyter notebooks for exploration
β”œβ”€β”€ configs/                       # Configuration files
β”œβ”€β”€ experiments/                   # Training logs and checkpoints
β”œβ”€β”€ outputs/                       # Results, predictions, reports
└── tests/                         # Unit tests

πŸš€ Setup Instructions

Prerequisites

  • Python 3.10+
  • uv package manager

Installation

  1. Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create virtual environment and install dependencies:
# Initialize project with uv
uv venv

# Activate virtual environment
source .venv/bin/activate  # On macOS/Linux

# Install dependencies
uv pip install -e .
  1. Download FakeNewsNet dataset:
python scripts/download_dataset.py

πŸ”¬ Research Pipeline

Stage 1: Data Ingestion and Preprocessing

python src/data/preprocess.py --input data/raw --output data/processed

Stage 2: Graph Construction and Feature Engineering

python src/features/build_graph.py --config configs/graph_config.yaml

Stage 3: Model Training

python src/training/train_gat.py --config configs/model_config.yaml

Stage 4: Evaluation and Analysis

python src/evaluation/evaluate.py --checkpoint experiments/best_model.pt
python src/visualization/generate_reports.py

πŸ“ˆ Expected Results

Metrics

  • Accuracy
  • F1-Score
  • AUC-ROC
  • Explanation Fidelity

Visualizations

  • Propagation graphs
  • Attention-based influence maps
  • Confusion matrices
  • Performance summaries

πŸ§ͺ Usage Examples

Training a GAT Model

from src.models.gat_model import FakeNewsGAT
from src.training.trainer import GATTrainer

model = FakeNewsGAT(
    in_channels=768,
    hidden_channels=128,
    num_classes=2,
    num_layers=3
)

trainer = GATTrainer(model, train_loader, val_loader)
trainer.train(epochs=100)

Analyzing Key Spreaders

from src.evaluation.explainability import AttentionAnalyzer

analyzer = AttentionAnalyzer(model, graph_data)
key_spreaders = analyzer.identify_influential_users(top_k=20)
analyzer.visualize_propagation_tree(news_id='article_123')

πŸ“š Tech Stack

  • PyTorch Geometric: Graph neural networks
  • Transformers (HuggingFace): BERT embeddings
  • NetworkX: Graph construction and analysis
  • scikit-learn: Classical ML metrics and preprocessing
  • matplotlib/seaborn: Visualization

πŸ” Interpretability

All predictions are accompanied by:

  • Attention weight distributions
  • Top influential users in propagation chains
  • Propagation path visualizations
  • Feature importance analysis

πŸ“ Notes

  • Purpose: Research and analysis only
  • Focus: Code efficiency and model accuracy
  • Interpretability: Attention weights logged and visualized for all predictions

πŸ“„ License

MIT License - For research purposes only

🀝 Contributing

This is a research project. For questions or collaboration, please open an issue.

πŸ“§ Contact

[Your contact information]

About

Fake news detection on social-media propagation graphs using GATv2 and the FakeNewsNet dataset.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages