def adjustedMutualInformation(cluster1, cluster2):

    cont = contingency(cluster1, cluster2)
    mi = mutualInformation(cluster1, cluster2)
    sample_size = float(sum([len(cluster1[x]) for x in cluster1.keys()]))

    # Given the number of samples, what is the expected number
    # of overlaps that would occur by chance?
    emi = supervised.expected_mutual_information(cont, sample_size)

    # calculate the entropy for each clustering
    h_clust1, h_clust2 = entropy(cluster1), entropy(cluster2)

    if abs(h_clust1) == 0.0:
        h_clust1 = 0.0
    else:
        pass
    if abs(h_clust2) == 0.0:
        h_clust2 = 0.0
    else:
        pass

    ami = (mi - emi) / (max(h_clust1, h_clust2) - emi)

    # bug: entropy will return -0 in some instances
    # make sure this is actually 0 else ami will return None
    # instead of 0.0

    if np.isnan(ami):
        ami = np.nan_to_num(ami)
    else:
        pass

    return ami


#################################################
# Data transformation and normalisation functions
#################################################
Using the scikit-learn algorithms, calculate the adjusted mutual
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Timeseries/__init__.py/adjustedMutualInformation