# 1.Cosine Similarity

## 27.05.2020

### Contents/Index

@1.Cosine Similarity

The cosine similarity between two vectors is defined to be the equal to the cosine angle between them. This is same as the inner product of the two vectors normalized to have length 1. For vectors $A$ and $B$ the cosine is given as $$A \cdot B = ||A||\ || B || cos \theta$$ Now the similarity is given as $$similarity = cos(\theta) = \frac{A \cdot B}{||A||\ ||B||} = \frac{\sum_{i = 1} A_i B_i}{ \sqrt{\sum_{i = 1} A_i^{n} }\ \sqrt{\sum_{i = 1} B_i^{2} } }$$ The result is in the range $[-1,1]$ where -1 means opposite and 1 means exactly the same. 0 indicates decorrelation.

The cosine similarity is often used to describe similarities between objects given vectors of attributes.