where:
- $a \cdot b$ is the dot product of $a$ and $b$
- $|a|$ and $|b|$ are the magnitudes (or norm) of $a$ and $b$, respectively.
#Interpretation
The cosine similarity measures the cosine of the angle between the two vectors. The value of $\cos \theta$ ranges from -1 to 1, where:
- $\cos \theta = 1$ means the vectors are identical (i.e., the angle between them is 0°)
- $\cos \theta = -1$ means the vectors are opposite (i.e., the angle between them is 180°)
- $\cos \theta = 0$ means the vectors are orthogonal (i.e., the angle between them is 90°)
#Properties
- Cosine similarity is a measure of similarity, not distance.
- It is sensitive to the direction of the vectors, not their magnitude.
- It is often used in text analysis, information retrieval, and recommender systems.
#Example
Suppose we have two vectors:
- $a = (1, 2, 3)$
- $b = (4, 5, 6)$ The Dot Product of $a$ and $b$ is:
This means that the vectors $a$ and $b$ are very similar, with an angle of approximately 14° between them.
#Applications
Cosine similarity is widely used in:
- Text analysis and information retrieval
- Recommender systems
- Image and video analysis
- Natural language processing
- Machine learning and data mining