Skip to content

Instantly share code, notes, and snippets.

@DozenCoder
Last active April 27, 2018 05:33
Show Gist options
  • Save DozenCoder/940ee462f5311a4b4bd18189aef1a23e to your computer and use it in GitHub Desktop.
Save DozenCoder/940ee462f5311a4b4bd18189aef1a23e to your computer and use it in GitHub Desktop.
用户相似度计算1
# similarity method 1
sim = 0
sim = sum([math.pow(r1[i] - r2[i]) for i in item_comm])/len(item_comm)
sim = math.sqrt(sim)
sim = 1.0 - math.tanh(sim)
# similarity method 2
max_comm = min(len(user1), len(user2))
sim = sim * item_comm / max_comm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment