Skip to content

Commit

Permalink
Test using candidate_items
Browse files Browse the repository at this point in the history
  • Loading branch information
myui committed Dec 11, 2024
1 parent 6462392 commit 8038566
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rtrec/models/slim.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def _recommend(self, user_id: int, top_k: int = 10, filter_interacted: bool = Tr
:return: List of top-K item indices recommended for the user
"""
interaction_matrix = self.interactions.to_csr(select_users=[user_id])
return self.model.recommend(user_id, interaction_matrix, top_k=top_k, filter_interacted=filter_interacted)

# Get candidate items for recommendation
candidate_item_ids = self.interactions.get_all_non_interacted_items(user_id) if filter_interacted else self.interactions.get_all_non_negative_items(user_id)

return self.model.recommend(user_id, interaction_matrix, candidate_item_ids, top_k=top_k, filter_interacted=filter_interacted)

def _recommend_batch(self, user_id: int, interaction_matrix: csc_matrix, candidate_item_ids: Optional[List[int]]=None, top_k: int = 10, filter_interacted: bool = True) -> List[int]:
"""
Expand Down

0 comments on commit 8038566

Please sign in to comment.