Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@HeenaR17
Created December 21, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeenaR17/199a3c39a2a01644fa14a834f0df815e to your computer and use it in GitHub Desktop.
Save HeenaR17/199a3c39a2a01644fa14a834f0df815e to your computer and use it in GitHub Desktop.
def cosine_similarity(x1, x2):
return np.round(np.dot(x1, x2)/(np.linalg.norm(x1)*np.linalg.norm(x2)),5)
print(cosine_similarity(word2vec.get_vector("winter"), word2vec.get_vector("summer")))
word2vec.similarity("winter","summer")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment