Skip to content

Commit 8b91724

Browse files
committed
Testing recommendations()
1 parent ef08d3a commit 8b91724

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

ratings.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@ def get_paper_ids(self):
2727
self.papers.append(paper)
2828
self.papers.sort()
2929

30-
def recommendations():
31-
allrecommendations = {}
32-
for person in self.persons:
33-
minimum = len(self.papers)*25+1
34-
for otherperson in self.persons.remove(person):
35-
closest = otherperson
36-
tmp = compare_ratings(person, otherperson)
37-
if tmp < minimum:
38-
closest = otherperson
39-
minimum = tmp
40-
notread = np.where(np.array(self.myratings[person] == 0))
41-
maxindex = np.where(self.myratings[otherperson][notread] == self.myratings[otherperson][notread].max())
42-
allrecommendations[person] = self._data[otherperson][maxindex]
43-
return allrecommendations
4430

4531
def compare_ratings(person1, person2):
4632
# only check non-zero ratings
@@ -50,6 +36,22 @@ def compare_ratings(person1, person2):
5036
cmp2 = self.myratings[person2][indices]
5137
return np.linalg.norm(self.myratings[cmp1] - self.myratings[cmp2])
5238

39+
def recommendations():
40+
return None
41+
#import pdb; pdb.set_trace()
42+
#allrecommendations = {}
43+
#for person in self.persons:
44+
# minimum = len(self.papers)*25+1
45+
# for otherperson in self.persons.remove(person):
46+
# tmp = compare_ratings(person, otherperson)
47+
# if tmp < minimum:
48+
# closest = otherperson
49+
# minimum = tmp
50+
# notread = np.where(np.array(self.myratings[person] == 0))
51+
# maxindex = np.where(self.myratings[otherperson][notread] == self.myratings[otherperson][notread].max())
52+
# allrecommendations[person] = self._data[otherperson][maxindex]
53+
#return allrecommendations
54+
5355
# Alternative distances:
5456
# pearson
5557
# tanimoto scipy.spatial.distance.rogerstanimoto

0 commit comments

Comments
 (0)