Skip to content

Commit

Permalink
Add k=None to rank() method in some models
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuddo committed Apr 22, 2024
1 parent 018dff7 commit 1aa722d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cornac/models/comparer/recom_comparer_obj.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ class ComparERObj(Recommender):
item_score = self.U2[item_id, :].dot(self.U1[user_id, :]) + self.H2[item_id, :].dot(self.H1[user_id, :])
return item_score

def rank(self, user_id, item_ids=None):
def rank(self, user_id, item_ids=None, k=None):
"""Rank all test items for a given user.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion cornac/models/comparer/recom_comparer_sub.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class ComparERSub(MTER):

return correct, skipped, loss, bpr_loss

def rank(self, user_idx, item_indices=None):
def rank(self, user_idx, item_indices=None, k=None):
if self.alpha > 0 and self.n_top_aspects > 0:
n_top_aspects = min(self.n_top_aspects, self.num_aspects)
ts1 = np.einsum("abc,a->bc", self.G1, self.U[user_idx])
Expand Down
2 changes: 1 addition & 1 deletion cornac/models/efm/recom_efm.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class EFM(Recommender):
item_score = self.U2[item_idx, :].dot(self.U1[user_idx, :]) + self.H2[item_idx, :].dot(self.H1[user_idx, :])
return item_score

def rank(self, user_idx, item_indices=None):
def rank(self, user_idx, item_indices=None, k=None):
"""Rank all test items for a given user.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion cornac/models/lrppm/recom_lrppm.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class LRPPM(Recommender):
item_score = self.I[i_idx].dot(self.U[u_idx])
return item_score

def rank(self, user_idx, item_indices=None):
def rank(self, user_idx, item_indices=None, k=None):
if self.alpha > 0 and self.num_top_aspects > 0:
n_items = self.num_items
num_top_aspects = min(self.num_top_aspects, self.num_aspects)
Expand Down

0 comments on commit 1aa722d

Please sign in to comment.