Created
January 15, 2022 15:09
-
-
Save eileen-code4fun/afe3b72bb055d68dd0df34c808b95b27 to your computer and use it in GitHub Desktop.
Project Paraphrases Embedding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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