0
$\begingroup$

I have, for example, the following lists of words that I want to cluster. The lists could have different lengths, and the vocabulary is $W = \{a,b,c\}$. The criteria of clustering 2 lists into a same cluster is that "the more they overlap, the more similar they are."

Index List Embedding
1 $[a,a,b,c]$ $[2,1,1]$
2 $[b,b,c]$ $[0,2,1]$
3 $[a,b,c,c,c]$ $[1,1,3]$
4 $[a,a,a]$ $[3,0,0]$

I have seen some problems with the classic clustering method (e.g. Kmeans) using the Euclidean distance is that $[a], [b],$ and $[c]$ (having the embeddings $[1,0,0], [0,1,0],$ and $[0,0,1]$) could be clustered into a same cluster even though there are non-overlapped events in the lists. And also Kmeans is not a good clustering method when the embedding is integer and could consist a lot of 0.

Which distance and which clustering method should I use for this clustering problem? Or should I use some different embeddings here?

$\endgroup$

1 Answer 1

0
$\begingroup$

Your definition of similarity:

The criteria of clustering 2 lists into a same cluster is that "the more they overlap, the more similar they are.

makes me think about Kmeans but with cosine similarity as distance definition.

If you consider

$$ [a] = [1,0,0]\\ [b] = [0,1,0]\\ [c] = [0,0,1] $$

you can think these embeddings as three perpendicular vectors inside a $\mathbb{R}^3$ vectorial space and in particular as its base (i.e. $\widehat{i}, \widehat{j},\widehat{k}$).

In this case to measure how much two verctors overlap, it's the same of calculating the angle between them, and cosine similarity does this.

Note that cosine similarity doesn't take into account vectors magnitude, so two records like $[a,a]$ and $[a,a,a,a,a]$ ($[2,0,0]$ and $[5,0,0]$) will be considered equal (because they have same orientation in the space).

$\endgroup$
2
  • $\begingroup$ Can I have some distance metric that can take into account both the direction of the vector and the magnitude of the vector as well? The frequency of the words is also important to consider. $\endgroup$
    – Diep Luong
    Commented Aug 5 at 11:27
  • $\begingroup$ In this case you can use the inner product (or dot product) between two vectors, that is the cosine similarity but without the normalization in [-1,1] range. $\endgroup$ Commented Aug 5 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.