DEFINITION
Cosine similarity is the cosine of the angle between vectors; that is, it is the dot product of the vectors divided by the product of their lengths
— https://en.wikipedia.org/wiki/Cosine_similarity
where is the magnitude of vector , which in general is defined as .
The cosine distance is defined as follows:
but often it is defined without the square root, since it maintains the same relative order between the elements and it is easier to compute:
Note that the cosine distance is not a true metric distance, since it does not have the triangular inequality and violates the coindicence axiom.
Convert to euclidean or Angular Distance is the true metric version of cosine distance.
See also
- Angular Distance is the true metric version of cosine distance — angular distance is the metric-compliant version derived from cosine similarity
- SimHash - h(x) = sign(wᵀx) — SimHash’s collision probability is a direct function of cosine similarity:
- Clustering is the task of grouping a set of objects — cosine similarity is one of the core choices for the similarity function in clustering, especially for text and high-dimensional vectors