Suppose I have a multitude of sets with (unordered) combinations of elements and I want to determine which elements tend to appear together.
For example
Given the following sets:
{a,e,g}
{a,e,h}
{a,e,i}
{b,f,j}
{b,f,k}
{b,f,l}
{d,c,m}
{d,c,n}
{d,c,o}
Element-pairs where both elements tend to occur in the same sets will have lower distance:
# Low-distance pairs:
{a,e}, {b,f}, {d,c}
# Medium-distance pairs
{a,g}, {b,j}, {d,m}, ...
# High-distance pairs:
{g,h}, {j,n}, {b,f}, ...
Currently
I'm implementing DBSCAN with a custom distance metric. I use the following distance metric between two elements:
d(a,b) = 1 - numsets(a, b) / (numsets(a,!b) + numsets(b,!a))
Where d(a,b)
denote the distance between elements a
and b
. While numsets
denotes how many sets fulfill some conditions:
numsets(a, b)
- the number of sets that containa
andb
numsets(a,!b)
- the number of sets that containa
but notb
This solution should achieve the goal however it's not a pretty solution and I couldn't find this problem on SE. In terms of solving the problem, is there a more sensible distance metric? In terms of implementation, is there a nicer way to do this?