Skip to content

Instantly share code, notes, and snippets.

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 kanekomasahiro/198cdc20ab7930ccd9ca26d84a0bc2f6 to your computer and use it in GitHub Desktop.
Save kanekomasahiro/198cdc20ab7930ccd9ca26d84a0bc2f6 to your computer and use it in GitHub Desktop.
numpyでベクトルのコサイン類似度を計算する
import numpy as np
def calculate_vector_cosine_similarity(vector1, vector2):
return np.dot(vector1, vector2) / (np.linalg.norm(vector1) * np.linalg.norm(vector2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment