def contingency(cluster1, cluster2):
    cont = pd.DataFrame(columns=cluster1.keys(), index=cluster2.keys())
    cont = cont.fillna(0.0)

    for x in itertools.product(cluster1.keys(), cluster2.keys()):
        set1 = cluster1[x[0]]
        set2 = cluster2[x[1]]
        intersect = len(set1.intersection(set2))
        cont[x[0]][x[1]] = intersect

    cont = cont.as_matrix()
    return cont
Return a n x m matrix of clustering overlaps, where n
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Timeseries/__init__.py/contingency