I fave my functions defined and no error while running the program. The problem is that nothing really happening when I try to call a function.
from math import sqrt
from recommendations import critics
def sim_distance(prefs, p1, p2):
si = {}
for item in prefs[p1]:
if item in prefs[p2]:
si[item] = 1
# If they have no ratings in common, return 0
if len(si) == 0:
return 0
# Add up the squares of all the differences
sum_of_squares = sum([pow(prefs[p1][item] - prefs[p2][item], 2) for item in prefs[p1] if item in prefs[p2]])
return 1 / (1 + sqrt(sum_of_squares))
reload (recommendations)
sim_distance(critics, 'Jack Matthews', 'Toby')