Described in this article are the concepts behind the distance and similarity measures using trigonometric functions. Specifically, the computation of cosine similarity, cosine distance, angular similarity and angular distance, using Python.
Consider two vectors: A and B.
The cosine similarity, cos(θ), is represented using the dot product and the magnitude of those two vectors, as follows:
The cosine distance is the complement of cosine similarity in positive space. It is computed as follows:
The angular distance is a formal distance metric and can be calculated from the cosine similarity. It is computed as follows:
The angular similarity is the complement of the angular distance metric. It is computed as follows:
Implementing cosine similarity, cosine distance, angular similarity and angular distance
Moad Computer is an actionable insights firm. We provide enterprises with end-to-end artificial intelligence solutions. Actionable Insights blog is a quick overview of things we are most excited about.