David watson
David watson

Reputation: 21

Euclidean Distance

I have some problem understanding euclidean distance. I have two different entities and I want to measure the similarity between these entities.

Lets suppose that entity A has 2 feature vectors and entity B has 1 feature vector only. How am I supposed to calculate the euclidean distance between these two entities in order to know the similarity?

Thanks a lot.

Upvotes: 1

Views: 3305

Answers (3)

Chris A.
Chris A.

Reputation: 6887

This is not a bad question at all.

Sometimes mathematicians define the Euclidean distance between two sets (A and B) of elements as the minimum distance between any two pairs of elements from either set.

You can also use the maximum over these two sets. That is called the Hausdorff distance.

Distance between two sets

In other words, you can compute the Euclidean distance between each element of set A to each element of set B and then define the distance, d(A,B), between the two sets as the minimum (or maximum) distance of any of the element pairs that you've computed.

Hausdorff (maximum) distance has some nicer mathematical properties and on the space of non-empty, compact sets (which your element will be since they are discrete) it will be a proper mathematical distance, in that it satisfies:

For all non-empty compact sets A,B,C

  1. d(A,B) >= 0 (with d(A,B) = 0 if and only if A=B)
  2. d(A,B) = d(B,A)
  3. d(A,B) <= d(A,C) + d(C,B)

Upvotes: 1

carlosdc
carlosdc

Reputation: 12132

L2 is between two feature vectors. These two would be natural ways of doing it:

You could find the minimum L2 distance between all the feature vectors of entity 1 and all the feature vectors of entity 2. If we have 2 vector for entity 1 like A=[1,3,2,1] and B=[3,2,4,1] AND 1 vector for entity 2 like C=[1,2,4,2]. Then dist = min(d([1,3,2,1],[1,2,4,2]),d([3,2,4,1],[1,2,4,2])

You could find the average vectors between all the vectors of entity 1 and the average vector of entity 2. Then compute the L2 distance. If we have 2 vector for entity 1 like A=[1,3,2,1] and B=[3,2,4,1] AND 1 vector for entity 2 like C=[1,2,4,2]. Then dist = d([(1+3)/2,(3+2)/2,(2+4)/2,(1+1)/2],[1,2,4,2])

Upvotes: 1

Nikolaus Gradwohl
Nikolaus Gradwohl

Reputation: 20124

you can calculate the eucledean distance only for vectors of the same dimension. But you could define some default values for the features that are missin in entity 2

Upvotes: 1

Related Questions