Answers for "what is use cosine similarity python"

1

cosine similarity python numpy

from scipy import spatial

dataSetI = [3, 45, 7, 2]
dataSetII = [2, 54, 13, 15]
result = 1 - spatial.distance.cosine(dataSetI, dataSetII)
Posted by: Guest on September-20-2020
2

cosine similarity python

from numpy import dot
from numpy.linalg import norm

def cosine_similarity(list_1, list_2):
  cos_sim = dot(list_1, list_2) / (norm(list_1) * norm(list_2))
  return cos_sim
Posted by: Guest on February-18-2021

Code answers related to "what is use cosine similarity python"

Python Answers by Framework

Browse Popular Code Answers by Language