Giter Site home page Giter Site logo

seyongk / fake-news-detection Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 272 KB

Code for detecting fake news using the User Preference-aware Fake News Detection (UPFD) dataset with attention to multi-modal embedding fusion.

License: MIT License

Jupyter Notebook 97.36% Python 2.64%

fake-news-detection's Introduction

Fake News Detection with UPFD Dataset

This repository contains code for fake news detection using the UPFD (User Preference-aware Fake News Detection) dataset. The UPFD dataset is a benchmark dataset for fake news detection that includes news propagation graphs extracted from Twitter. You can find more information about the dataset at https://paperswithcode.com/dataset/upfd.

Dataset

The UPFD dataset consists of news propagation graphs extracted from Twitter. The source and raw data can be found at https://github.com/KaiDMML/FakeNewsNet. The preprocessing steps are described in the paper: https://arxiv.org/pdf/2104.12259.pdf.

The dataset is split into train and test sets. The node features are represented by a combination of Spacy Word2Vec embeddings and profile features.

Models

Two models are implemented in this repository:

  1. GNN (Graph Neural Network): A graph neural network model that uses graph convolutions and pooling to learn node embeddings and make predictions.

  2. GNNWithAttentionFusion: An extension of the GNN model that incorporates attention-based fusion of node embeddings and news embeddings.

Training and Evaluation

The code provides a Trainer class that handles the training and evaluation of the models. The trainer is initialized with the model, loss function, optimizer, and device (CPU or GPU).

The training process is performed using the train method of the trainer, which iterates over the training data loader and updates the model parameters.

Evaluation is done using the test method of the trainer, which computes the test loss, accuracy, and F1 score on the test data loader.

Results

The repository includes code to visualize the training and evaluation results. The loss, accuracy, and F1 score are plotted over epochs for different models and learning rates.

Additionally, t-SNE (t-Distributed Stochastic Neighbor Embedding) is used to visualize the learned node embeddings in a 2D space.

Usage

To run the code, make sure you have the required dependencies installed. You can install them using the following command:

pip install -r requirements.txt

The main code is provided in the main.ipynb notebook. You can run the notebook cells sequentially to load the dataset, train the models, and visualize the results.

Acknowledgments

The code in this repository is mainly based on the UPFD colab tutorial available at https://colab.research.google.com/drive/1ZVZdehPPod6o4sF64QZa8I3NoSOH8MmC?usp=sharing.

License

This project is licensed under the MIT License.

Feel free to contribute, provide feedback, or report any issues you encounter while using this code.

fake-news-detection's People

Contributors

seyongk avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.