Skip to content

vinzlercodes/Document-Classification-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Document-Classification-Algorithm

Title: Document Classification using Hierarchical Attention Networks

Author:

About:

In this repository, we use 50,000 IMDb movie reviews, specially selected for sentiment analysis, as well as implement an newly-adapted and improved version of a Paper, written by Yang et al. from the 2016 NAACL called Hierarchical Attention Networks for tackling Document Classification.

Contents

  • Document_Classifier.ipynb (Models Folder) - This notebook contains, the actual modelling of the Hierarchial Attention Network, it then takes in the data (avalialble in the data folder) and utilisng the model classifies sentences in the document and assigns attention values (more attention = sentence is important for classification of the document, less attention = sentence is not very important for classification of the document).
  • Sentence_Classifier.ipynb (Models Folder) - This notebook contains, the actual modelling of the Hierarchial Attention Network, it then takes in the data (avalialble in the data folder) and utilisng the model classifies words in the sentences of the document and assigns attention values (more attention = sentence is important for classification of the sentence and ultimately the document, less attention = sentence is not very important for classification of the sentence and ultimately the document).
  • Data Folder - The folder consists of the raw data set used.
  • NLP_Project_Report - PDF file consisting of a comprehensive writeup of the entire project implementation and also comparison to the paper to which this algorithm is compared to.

Requirements

  • Python 3
  • numpy
  • pandas
  • BeautifulSoup
  • Matplotlib
  • tensorflow
  • keras
  • (optional) CUDA cores

How to Run

  • Clone the project
  • Check if all library/package dependancies are fulfilled, if not install them.
    • The project does not use too many external dependancies hence, you only need to install them using the command !pip install (package_name) in jupyter notebook cell, just before importing them.
  • Make sure you have the data as well downloaded.
  • Then just run both the files and everything should work fine.

If there are any issues, please do reach out to me

Dataset

An analysis of 50,000 IMDB movie reviews was conducted for the labeled data set. Reviews are scored as binary sentiment, so a 5-star IMDB rating results in a score of 0, and a rating >=7 results in a score of 1. The sentiment of reviews is derived from what is written about each movie. It does not contain any movies that are part of the test set with 25,000 reviews. Furthermore, IMDB reviews without labels are available for another 50,000 titles.

Models used

  • Hierarchical Attention Network for Sentence Classification

  • Hierarchical Attention Network for Word Classification

Result

  • Hierarchical Attention Network for Document Classification

download2

  • Document Classification

download (3)

  • Hierarchical Attention Network for Sentence Classification

download

  • Sentence Classification

download (2)

Author Model Data Set Accuracy
Yang et al. HN-ATT IMDB 49.4
Vinayak (me) HN-GRU (Document) IMDB 88.4
Vinayak (me) HN-GRU (Sentence) IMDB 84.4

About

This repository contains project resources to create a document classification algorithm in practise

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors