练习1
Tanimoto分值
公式:
def sim_tanimoto(prefs, p1, p2):
common = 0
for item in prefs[p1]:
if item in prefs[p2]:
common += 1
if common == 0: return 0
count1 = len(prefs[p1])
count2 = len(prefs[p2])
r = common / float(count1 + count2 - common)
return r