# How to Measure/Quantify Similarity between > 2 Sets of Dummies Indicators

I have multiple sets, each with a binary indicator for whether an element is part of the set.

     a  b  c  d  e
set
1    1  0  1  1  1
2    1  0  0  1  1
3    0  1  0  1  1
4    0  1  0  1  1


I would like to create some statistic that measures the similarity between all of these sets. If there were only two sets, I could use something like the Jaccard Index, or the simple matching coefficient (since in this case 1 and 0 carry equivalent information), but I cannot seem to find anything that generalizes to many sets.

My naive thought was to calculate all pair-wise SMCs (in this case 6), and then take the average. Assuming the above is my pandas.DataFrame named df:

from sklearn.metrics.pairwise import pairwise_distances
import pandas as pd
import numpy as np

df_sim = 1 - pairwise_distances(df, metric='hamming')
df_sim = pd.DataFrame(df_sim, index=df.index, columns=df.index)
#set    1    2    3    4
#set
#1    1.0  0.8  0.4  0.4
#2    0.8  1.0  0.6  0.6
#3    0.4  0.6  1.0  1.0
#4    0.4  0.6  1.0  1.0

np.mean((df_sim.to_numpy())[np.triu_indices(df.shape[0], k=1)])
#0.633


Is this sensible, or is there a better way or some flaw I may be overlooking?

• Several measures extend to muliple dimensions. Try searching for "multiclass cross entropy" for example. – Frans Rodenburg May 27 at 6:51