Learning Cosine Similarity
Cosine similarity measures how closely two vectors point in the same direction: cos(θ) = (A · B) / (‖A‖ × ‖B‖). For A = [1, 0] and B = [1, 1], the angle is 45° and the cosine similarity is 0.707.
Please turn on JavaScript to drag the vectors and explore.
Cosine similarity formula
cos(θ) = (A · B) / (‖A‖ × ‖B‖) A · B = A₁B₁ + A₂B₂ + … + AₙBₙ ‖A‖ = √(A₁² + A₂² + … + Aₙ²)