Skip to content

Commit

Permalink
fix get-item-based-k
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentao Dai committed Dec 25, 2019
1 parent af16d38 commit 91c65d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions azureml-designer-modules/entries/score_sar_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def recommend_items(model, data, ranking_metric, top_k, sort_top_k, remove_seen,
raise ValueError(f"Got unexpected ranking metric: {ranking_metric}.")


def predict_ratings(model, data, items_to_predict, remove_seen, normalize):
def predict_ratings(model, data, items_to_predict, normalize):
if items_to_predict == ItemSet.TRAIN_ONLY:
return model.predict_training_items(test=data, normalize=normalize)
if items_to_predict == ItemSet.SCORE_ONLY:
Expand Down Expand Up @@ -101,7 +101,6 @@ def predict_ratings(model, data, items_to_predict, remove_seen, normalize):
score_result = predict_ratings(model=sar_model,
data=dataset_to_score,
items_to_predict=ItemSet(args.items_to_predict),
remove_seen=remove_seen_items,
normalize=normalize)
else:
raise ValueError(f"Got unexpected score type: {score_type}.")
Expand Down
2 changes: 1 addition & 1 deletion azureml-designer-modules/module_specs/sar_score.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: SAR Score
version: 0.0.19
version: 0.0.20
category: Experimentation
description: |
Python SAR Recommender
Expand Down
8 changes: 7 additions & 1 deletion reco_utils/recommender/sar/sar_singlenode.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,13 @@ def get_item_based_topk(self, items, top_k=10, sort_top_k=True):
"""

# convert item ids to indices
item_ids = items[self.col_item].map(self.item2index)
items[self.col_item] = items[self.col_item].map(self.item2index)
if any(items.isna()):
logger.warning("Items found in test not seen during training, new items won't be considered as "
"seed item of recommendations.")
items = items.dropna()

item_ids = items[self.col_item].astype(int)

# if no ratings were provided assume they are all 1
if self.col_rating in items.columns:
Expand Down

0 comments on commit 91c65d5

Please sign in to comment.