Skip to content

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ₙ²)

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

One short email when a new calculator or article goes live. No spam, and you can unsubscribe in one click.