Last active
April 27, 2018 05:33
-
-
Save DozenCoder/940ee462f5311a4b4bd18189aef1a23e to your computer and use it in GitHub Desktop.
用户相似度计算1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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