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.
Cosine similarity
The cosine similarity, cos(θ), is represented using the dot product and the magnitude of those two vectors, as follows:
Cosine distance
The cosine distance is the complement of cosine similarity in positive space. It is computed as follows:
Angular distance
The angular distance is a formal distance metric and can be calculated from the cosine similarity. It is computed as follows:
Angular similarity
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
Library imports
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
OverviewMoad 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. Archives
November 2022
Categories |