sklearn cosine_similarity vs pairwise_distances

>>> from sklearn.metrics.pairwise import cosine_similarity
>>> from sklearn.metrics.pairwise import pairwise_distances
>>> a=[[1,3],[2,2]]
>>> cosine_similarity(a)
array([[ 1.        ,  0.89442719],
       [ 0.89442719,  1.        ]])
>>> pairwise_distances(a,metric="cosine")
array([[ 0.        ,  0.10557281],
       [ 0.10557281,  0.        ]])
>>> 

Cosine distance 等于 1.0 减 cosine similarity.

你可能感兴趣的:(sklearn cosine_similarity vs pairwise_distances)