1
$\begingroup$

I have two sets $S_1=\{1,2,3,4\}$ and $S_2\{1,2,3,4,5,6,7,8,9\}$.

  • $Intersection (I) = 4$
  • Number of non-equal elements (N) = $5$

I am trying to find a way to combine the intersection and number of non-equal elements to compute the similarity between the two sets. The higher the number of non-equal elements the lower the similarity


Solution (Gerry Myerson) Let $I$ be the size of the intersection, $N$ the number of non-equal elements. The similarity between $S_1$ and $S_2$ is then $I~/~(N+1)$

$\endgroup$
  • 2
    $\begingroup$ Let $I$ be the size of the intersection, $N$ the number of non-equal elements. You could use $I/(N+1)$. $\endgroup$ – Gerry Myerson May 2 '14 at 9:04
  • $\begingroup$ @GerryMyerson I just have one problem. How can I normalize it between $0$and $1$. because suppose that $I = 6$ and $N = 2$ it wont be between $0$ and $1$ that's what i am trying to figure out now. $\endgroup$ – Hani Gotc May 2 '14 at 9:19
  • $\begingroup$ If that's what you want, please edit it into your question. $\endgroup$ – Gerry Myerson May 2 '14 at 12:39
2
$\begingroup$

As Gerry suggested:

$$sim(S_1,S_2) = |S_1 \cap S_2| ~/~ (|S_1 {\tiny \triangle}~ S_2| + 1),$$

where the triangle is the symmetric difference. We can try to normalize it as follows:

$$norm(S_1,S_2) = sim(S_1,S_2) ~/~ |S_1 \cup S_2|.$$

Of course, whenever $|S_1 \cup S_2| = 0$, we let $norm(S_1,S_2) = 0$.

$\endgroup$
  • $\begingroup$ Is it possible to normalize it between $0$ and $1$? $\endgroup$ – Hani Gotc May 2 '14 at 9:22
  • $\begingroup$ I've updated the answer. See if that's what you want. $\endgroup$ – Hunan Rostomyan May 2 '14 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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