Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove drop_duplicates() from SAR method fix #1464 #1588

Merged
merged 10 commits into from
Feb 28, 2022
13 changes: 5 additions & 8 deletions recommenders/models/sar/sar_singlenode.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ def set_index(self, df):
def fit(self, df):
"""Main fit method for SAR.

.. note::

Please make sure that `df` has no duplicates.

Args:
df (pandas.DataFrame): User item rating dataframe
df (pandas.DataFrame): User item rating dataframe (without duplicates).
"""

# generate continuous indices if this hasn't been done
if self.index2item is None:
self.set_index(df)
Expand All @@ -226,12 +229,6 @@ def fit(self, df):
if self.time_decay_flag:
logger.info("Calculating time-decayed affinities")
temp_df = self.compute_time_decay(df=temp_df, decay_column=self.col_rating)
else:
# without time decay use the latest user-item rating in the dataset as the affinity score
logger.info("De-duplicating the user-item counts")
temp_df = temp_df.drop_duplicates(
[self.col_user, self.col_item], keep="last"
)

logger.info("Creating index columns")
# add mapping of user and item ids to indices
Expand Down