Skip to content

Commit

Permalink
sort by similarity only in KNNBasic (as before)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Sep 29, 2017
1 parent 49c33fa commit 632fd5c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion surprise/prediction_algorithms/knns.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def estimate(self, u, i):
x, y = self.switch(u, i)

neighbors = [(self.sim[x, x2], r) for (x2, r) in self.yr[y]]
k_neighbors = heapq.nlargest(self.k, neighbors)
k_neighbors = heapq.nlargest(self.k, neighbors, key=lambda t: t[0])

# compute weighted average
sum_sim = sum_ratings = actual_k = 0
Expand Down

0 comments on commit 632fd5c

Please sign in to comment.