GithubHelp home page GithubHelp logo

jsrpy / nlp_sentiment_analysis Goto Github PK

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

Examples of using Keras word embedding to perform sentiment analysis on IMDB and Reuters datasets.

License: MIT License

Jupyter Notebook 100.00%
python keras-implementations word-embeddings sentiment-classification natural-language-processing

nlp_sentiment_analysis's Introduction

Sentiment_Analysis_Word_Embeddings

Examples of using Keras word embedding to perform sentiment classification on IMDB and Reuters datasets.

1.IMDB

This dataset contains 25,000 movie reviews from IMDB, labeled with sentiment (positive or negative). The test data is of the same size (25,000) rows of data, i.e. it is ia 0.5 split by default.

A 1D Convolutional neural network is trained on the training set and tested.

Why 1D ConvNet?

Text data is sequential data. A 1D neural network is best at retaining and learning the sequential patterns in a corpus.

So generally speaking, we should use a 1D architecture whenever countering textual data.

Results:

  • Test Accuracy: 86.42%

2. Reuters_A

The Reuters datset contains 11,228 newswires from Reuters, labeled over 46 topics. Similar to the IMDB dataset, each wire is encoded as a sequence of integers.

A CNN is built to classify the news topic of each wire.

This attempt used a similar method as the IMDB sentiment classification, which means the sequence-of-integers representation of words is retained and directly fed into the convolutional embedding layer.

Results

This approach does not produce a satisfactory result. A second approach with higher accuracy is demonstrated in the next session.

  • Test Accuracy: 65.49%

3. Reuter_B

In this second attempt, the sequence-of-words-integers is vectorise as one-hot word vector, and then fed into a fully-connected perceptrons layer.

Results

This second approach is simplier in architecture and attains a higher accuracy than approach A!

  • Test Accuracy: 79.70%

Comparison between Reuters A & B Approach

Approach A attempts to retain to sequential meaning of natural language and use a convolutional neutral nets to learn that semantic meaning for topic classification. It turns out that it is unclear as to how the neural architecture should be set up to properly address this task, and the training time is longer as the matrix is sparse.

Approach B attempts to just use the one-hot word vector, i.e. looking at which words appear in a newswire and fed them directly to a fully-connected neurons to learn the topic relationship. It is fast to train and does not need to consider building up the convolutional layer.

Requirements:

  • keras

nlp_sentiment_analysis's People

Contributors

jsrpy avatar

Forkers

ferch91

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.