Skip to content

Implementation of Word2Vec on Game of Thrones corpora using Gensim

License

Notifications You must be signed in to change notification settings

FAKER-112/Word2Vec-Using-Gensim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Implementation of Word2Vec on Game of Thrones corpora using Gensim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Jupyter Notebook 100.0%