Search code examples
pythonscikit-learncosine-similarity

Python `sklearn.metrics.pairwise` `cosine_similarity` or `cosine_distance` theoretical range


Cosine similarity/distance should be bounded between -1 and +1. Yet, sklearn.metrics.pairwise gives values > +1. Can anyone explain this behaviour please?


Solution

  • pairwise default distance is Euclidean which is not bounded from above, hence you should not be surpised to see some values greater than 1.