http://en.wikipedia.org/wiki/Cosine_similarityhttp://www.appliedsoftwaredesign.com/cosineSimilarityCalculator.phpThe Cosine Similarity of two vectors a and b is the ratio: a dot b / ||a|| ||b||
Let d1 = {2 4 3 1 6}
Let d2 = {3 5 1 2 5}
Cosine Similarity (d1, d2) = dot(d1, d2) / ||d1|| ||d2||
dot(d1, d2) = (2)*(3) + (4)*(5) + (3)*(1) + (1)*(2) + (6)*(5) = 61
||d1|| = sqrt((2)^2 + (4)^2 + (3)^2 + (1)^2 + (6)^2) = 8.12403840464
||d2|| = sqrt((3)^2 + (5)^2 + (1)^2 + (2)^2 + (5)^2) = 8
Cosine Similarity (d1, d2) = 61 / (8.12403840464) * (8)
= 61 / 64.9923072371
= 0.938572618717
Comments top
No comments for cosine-similarity. Log in to add a comment.