How to visualize the SpaCy word embedding as scatter plot?

Viewed 805

Each word in SpaCy is represented by a vector of length 300. How can I plot these words on a scatter plot to get a visual perspective on how close any 2 words are?

2 Answers

When working with small-to-medium-sized texts, ScatterText is a tool which can be used to discover words that have distinguishing features. It also enables users to create interactive scatter plots that contain non-overlapping term labels.

Intall via -https://pypi.org/project/scattertext/

import spacy
import scattertext as st
nlp = spacy.load('en')
corpus = st.CorpusFromPandas(convention_df,
                         category_col='party',
                         text_col='text',
                         nlp=nlp).build()
Related