Python Script to calculate taste of two people based on the rating using Euclidean Distance Score

from math import sqrt
# 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)

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s