Skip to main content
Fixed math formatting
Source Link
Jan Kukacka
  • 11.5k
  • 1
  • 44
  • 70

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. Here's the explanation:

cosineCosine distance is actually cosine similarity: $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }}$$\cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }}$.

nowNow, let's see what we can do with euclidean distance for normalized vectors ($\sum x_i^2 =\sum y_i^2 =1)$$(\sum x_i^2 =\sum y_i^2 =1)$:

$||x-y||^2 =\sum(x_i -y_i)^2 =\sum (x_i^2 +y_i^2 -2x_iy_i)$ $ = \sum x_i ^2 +\sum y_i^2 -2\sum x_iy_i = 1+1-2cos(x,y)=2(1-cos(x,y)$$$\begin{align} ||x-y||^2 &=\sum(x_i -y_i)^2 \\ &=\sum (x_i^2 +y_i^2 -2x_iy_i) \\ &= \sum x_i ^2 +\sum y_i^2 -2\sum x_iy_i \\ &= 1+1-2\cos(x,y)\\ &=2(1-\cos(x,y)) \end{align}$$

noteNote that for normalized vectors $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }} =\sum x_iy_i$$\cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }} =\sum x_iy_i$

soSo you can see that there is a direct linear connection between these distances for normalized functionsvectors.

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. Here's the explanation:

cosine distance is actually cosine similarity: $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }}$

now, let's see what we can do with euclidean distance for normalized vectors ($\sum x_i^2 =\sum y_i^2 =1)$:

$||x-y||^2 =\sum(x_i -y_i)^2 =\sum (x_i^2 +y_i^2 -2x_iy_i)$ $ = \sum x_i ^2 +\sum y_i^2 -2\sum x_iy_i = 1+1-2cos(x,y)=2(1-cos(x,y)$

note that for normalized vectors $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }} =\sum x_iy_i$

so you can see that there is a direct linear connection between these distances for normalized functions

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. Here's the explanation:

Cosine distance is actually cosine similarity: $\cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }}$.

Now, let's see what we can do with euclidean distance for normalized vectors $(\sum x_i^2 =\sum y_i^2 =1)$:

$$\begin{align} ||x-y||^2 &=\sum(x_i -y_i)^2 \\ &=\sum (x_i^2 +y_i^2 -2x_iy_i) \\ &= \sum x_i ^2 +\sum y_i^2 -2\sum x_iy_i \\ &= 1+1-2\cos(x,y)\\ &=2(1-\cos(x,y)) \end{align}$$

Note that for normalized vectors $\cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }} =\sum x_iy_i$

So you can see that there is a direct linear connection between these distances for normalized vectors.

added 555 characters in body
Source Link
Cherny
  • 722
  • 5
  • 7

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. If you needHere's the explanation why I:

cosine distance is actually cosine similarity: $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }}$

now, let's see what we can add it here.do with euclidean distance for normalized vectors ($\sum x_i^2 =\sum y_i^2 =1)$:

$||x-y||^2 =\sum(x_i -y_i)^2 =\sum (x_i^2 +y_i^2 -2x_iy_i)$ $ = \sum x_i ^2 +\sum y_i^2 -2\sum x_iy_i = 1+1-2cos(x,y)=2(1-cos(x,y)$

note that for normalized vectors $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }} =\sum x_iy_i$

so you can see that there is a direct linear connection between these distances for normalized functions

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. If you need explanation why I can add it here.

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. Here's the explanation:

cosine distance is actually cosine similarity: $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }}$

now, let's see what we can do with euclidean distance for normalized vectors ($\sum x_i^2 =\sum y_i^2 =1)$:

$||x-y||^2 =\sum(x_i -y_i)^2 =\sum (x_i^2 +y_i^2 -2x_iy_i)$ $ = \sum x_i ^2 +\sum y_i^2 -2\sum x_iy_i = 1+1-2cos(x,y)=2(1-cos(x,y)$

note that for normalized vectors $cos(x,y) = \frac{\sum x_iy_i}{\sqrt{\sum x_i^2 \sum y_i^2 }} =\sum x_iy_i$

so you can see that there is a direct linear connection between these distances for normalized functions

Source Link
Cherny
  • 722
  • 5
  • 7

It should be the same, for normalized vectors cosine similarity and euclidean similarity are connected linearly. If you need explanation why I can add it here.