Created
March 13, 2018 19:37
-
-
Save dipanjanS/3557b2a27d4365e16890aee3e6e35dbe to your computer and use it in GitHub Desktop.
This file contains 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.metrics.pairwise import euclidean_distances | |
distance_matrix = euclidean_distances(weights) | |
print(distance_matrix.shape) | |
similar_words = {search_term: [id2word[idx] for idx in distance_matrix[word2id[search_term]-1].argsort()[1:6]+1] | |
for search_term in ['god', 'jesus', 'noah', 'egypt', 'john', 'gospel', 'moses','famine']} | |
similar_words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment