I didnβt do the course yet, forgive me if I understand it wrong.
Basically, we are discussing how close the vectors are.
Cosine similarity is much simpler to understand when the vectors modules are equal to 1.
In this case, the cosine similarity
(a . b . cos (π))
will be reduced to cos(π) that is, magically, the product of the matrices.
Letβs get 2 vectors in x, y bidimensional space:
A = [x1, y1] at an horizontal angle of π1
B = [x2, y2] at an horizontal angle of π2
if they are normalized, the cosine similarity or dot product between them will be
β£Aβ£ * β£Bβ£ * cos(π3)
where π3 = π2 - π1
and β£Aβ£ = β£Bβ£ = 1
but
cos( π2 - π1) = cos( π2)*cos( π1) + sen( π2)*sen( π1)
so, applying it to the definitions
we get that the cosine similarity will be:
As
A = [x1, y1]
and
B = [x2, y2]
Then the cosine similarity or dot product will be
We can see this also from the definition of cosine similarity:
cosine similarity=
β
If the vectors are not normalized, the calculation gets much more complicated: