def masi_distance(label1, label2):
 len_intersection = len(label1.intersection(label2))
 len_union = len(label1.union(label2))
 len_label1 = len(label1)
 len_label2 = len(label2)
 if ((len_label1 == len_label2) and (len_label1 == len_intersection)):
  m = 1
 elif (len_intersection == min(len_label1, len_label2)):
  m = 0.67
 elif (len_intersection > 0):
  m = 0.33
 else:
  m = 0
 return ((1 - (len_intersection / float(len_union))) * m)

def masi_distance ( label1 , label2 ) : len_intersection = len ( label1 . intersection ( label2 ) ) len_union = len ( label1 . union ( label2 ) ) len_label1 = len ( label1 ) len_label2 = len ( label2 ) if ( ( len_label1 == len_label2 ) and ( len_label1 == len_intersection ) ) : m = 1 elif ( len_intersection == min ( len_label1 , len_label2 ) ) : m = 0.67 elif ( len_intersection > 0 ) : m = 0.33 else : m = 0 return ( ( 1 - ( len_intersection / float ( len_union ) ) ) * m )
distance metric that takes into account partial agreement when multiple labels are assigned .