Created
August 25, 2015 13:54
-
-
Save finnp/780a48a46366be0f7a72 to your computer and use it in GitHub Desktop.
This file contains 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
def knearest(r_id, set_of_restaurants, db, k = 7, reg = 3.): | |
def getTupel(r): | |
sim, support = db.get(r_id, r) | |
shrunken_sim = shrunk_sim(sim, support, reg) | |
return (r, shrunken_sim, support) | |
rs = [getTupel(r) for r in set_of_restaurants] | |
return sorted(rs, key=lambda r: -r[1])[:k] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment