Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cosine_sim(x1,x2):
- sum_arr = x1+x2
- f11 = len(np.where(sum_arr == 2)[0])
- #return f11/(np.linalg.norm(x1) * np.linalg.norm(x2))
- return np.dot(x1.T, x2)/(np.linalg.norm(x1) * np.linalg.norm(x2))
- def jaccard_sim(x1,x2):
- sum_arr = x1+x2
- f11 = len(np.where(sum_arr == 2)[0])
- f00 = len(np.where(sum_arr == 0)[0])
- return f11/(len(x1) - f00)
- def smc_sim(x1, x2):
- sum_arr = x1+x2
- f11 = len(np.where(sum_arr == 2)[0])
- f00 = len(np.where(sum_arr == 0)[0])
- return (f00 + f11)/(len(x1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement