Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
sim-distance in python
# Returns a distance-based similarity score for person1 and person2
def sim_distance(prefs,person1,person2):
# Get the list of shared_items
for item in prefs[person1]:
if item in prefs[person2]:
# if they have no ratings in common, return 0
if len(si)==0: return 0
# Add up the squares of all the differences
for item in prefs[person1] if item in prefs[person2]])
return 1/(1+sum_of_squares)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.