1
5.9kviews
Find Cosine Distance between the d1 and d2 vectors:
Index 1 2 3 4 5 6 7 8 9 10
d1 5 2 1 0 0 0 0 1 3 7
d2 5 2 1 0 0 1 2 2 0 2
1 Answer
1
907views

Cosine distance $(d_1, d_2) = \frac{d1.d2}{||d1||.||d2||}$

d1.d2 = 5 x 5 + 2 x 2 + 1 x 1 + 0 + 0 + 0 + 0 + 1 x 2 + 0 + 7 x 2 = 25 + 4 + 1 + 2 + 14 = 46

|| d1 || = $\sqrt{25+4+1+1+9+49} = \sqrt{89}$

|| d2 || = $\sqrt{25 + 4 + 1 + 1 + 4 + 4 + 4} = \sqrt{43}$

Cosine distance (d1, d2) = $\frac{46}{ \sqrt{89}. \sqrt{43}} = \frac{46}{ \sqrt{3827}}$

= $\frac{46}{61.86}$ = 0.74

$\theta$ = cos + (0.74)

Please log in to add an answer.