Skip to content

Commit

Permalink
Support for cold-start in ImplicitCF
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddavo committed Jun 24, 2024
1 parent 211ee70 commit cb2b282
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion recommenders/models/deeprec/DataModel/ImplicitCF.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _data_processing(self, train, test):
user_idx = df[[self.col_user]].drop_duplicates().reindex()
user_idx[self.col_user + "_idx"] = np.arange(len(user_idx))
self.n_users = len(user_idx)
self.n_users_in_train = train[self.col_user].nunique()
self.user_idx = user_idx

self.user2id = dict(
Expand Down Expand Up @@ -210,7 +211,7 @@ def sample_neg(x):
if neg_id not in x:
return neg_id

indices = range(self.n_users)
indices = range(self.n_users_in_train)
if self.n_users < batch_size:
users = [random.choice(indices) for _ in range(batch_size)]
else:
Expand Down

0 comments on commit cb2b282

Please sign in to comment.