cosine_similarity returns matrix instead of single value
-
31-10-2019 - |
質問
I am using below code to compute cosine similarity between the 2 vectors. It returns a matrix instead of a single value 0.8660254
.
[[ 1. 0.8660254]
[ 0.8660254 1. ]]
from sklearn.metrics.pairwise import cosine_similarity
vec1 = [1,1,0,1,1]
vec2 = [0,1,0,1,1]
print(cosine_similarity([vec1, vec2]))
正しい解決策はありません
所属していません datascience.stackexchange