Skip to content

Instantly share code, notes, and snippets.

@eileen-code4fun
Created January 15, 2022 15:09
Show Gist options
  • Save eileen-code4fun/afe3b72bb055d68dd0df34c808b95b27 to your computer and use it in GitHub Desktop.
Save eileen-code4fun/afe3b72bb055d68dd0df34c808b95b27 to your computer and use it in GitHub Desktop.
Project Paraphrases Embedding
from sklearn.decomposition import PCA
def project(words, phrases, model):
embeddings = []
associated_words = []
pca = PCA(n_components=2)
for word in words:
associated_words.append(word)
embeddings.append(model[word])
for pphrase in phrases[word]:
associated_words.append(phrase)
embeddings.append(model[phrase])
return pca.fit_transform(embeddings), associated_words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment