Py = np.array([(len(y[y == yval]) / float(len(y))) for yval in y_value_list])
for i in range(len(x_value_list)):
    if Px[i] == 0.0:
        continue
sy = y[x == x_value_list[i]]
if len(sy) == 0:
    continue
pxy = np.array([(len(sy[sy == yval]) / float(len(y))) for yval in y_value_list]
    )
t = pxy[Py > 0.0] / Py[Py > 0.0] / Px[i]
sum_mi += sum(pxy[t > 0] * np.log2(t[t > 0]))
return sum_mi
Python's implementation of Mutual Information