Code Monkey home page Code Monkey logo

word2vec-using-gensim's Introduction

Word2Vec-Using-Gensim

This is an implementation of Word2Vec model using Gensim on Game of Thrones corpora.

Word2vec is a very popular Natural Language Processing technique, that uses a neural network to learn the vector representations of words called "word embeddings" in a particular text.

After training the Word2Vec model, we will use t-Distributed Stochastic Neighbor Embedding (t-SNE) from sklearn to visualize the learned embeddings vectors.

Dataset

Here, the Word2Vec model is trained on the Game of thrones corpora which consist of five books of Game of Thrones. Each corpus has been preprocessed to extract only the tokens and removed all the stopwords.

Requirements

This Word2Vec model is implemented using Gensim Packages.

pip install --upgrade gensim

Please check the requirements.txt file for all the packages which you need to install. Most of the packages can be installed using the pip package manager.

Training the model

The model is trained for 50 epochs for 5 times and the sentences in the corpora are shuffled for each time. After training the model, let's see some of the results.

model.wv.most_similar('stark')

screen shot 2018-09-11 at 9 47 38 pm

model.wv.most_similar('aerys')

screen shot 2018-09-11 at 9 48 05 pm

Model Visualization

We visualize the learned embeddings using t-SNE. It is a tool for data visualization that reduces the dimensionality of data to 2 or 3 dimensions so that it can be plotted easily.

Let's visualize the entire data

screen shot 2018-09-11 at 9 56 09 pm

Let's visualize a particular bag of words

screen shot 2018-09-11 at 9 57 05 pm

Discussion

Word2Vec model can be an important process in Deep Learning where each text can be represented in the form of word embeddings so that deep neural network can understand better.

Have questions? Need help with the code?

If you're having issues with or have questions about the code, file an issue in this repository so that I can get back to you soon.

word2vec-using-gensim's People

Contributors

aravindmanoharan 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.