diff --git a/chapter2/recommendations.py b/chapter2/recommendations.py index c3f0089..976a7b5 100644 --- a/chapter2/recommendations.py +++ b/chapter2/recommendations.py @@ -35,7 +35,7 @@ def sim_distance(prefs,person1,person2): sum_of_squares=sum([pow(prefs[person1][item]-prefs[person2][item],2) for item in prefs[person1] if item in prefs[person2]]) - return 1/(1+sum_of_squares) + return 1/(1+sqrt(sum_of_squares)) # Returns the Pearson correlation coefficient for p1 and p2 def sim_pearson(prefs,p1,p2):