Skip to content

Commit

Permalink
adding duplicate patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-dhanwant-yral committed Aug 23, 2024
1 parent e5e9664 commit 5b4f6ee
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion python_src/recommendation_service/simple_recommendation_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,23 @@ def calculate_exploit_score(len_sample, len_required): # to be replaced with RL
[recency_exploitation_score] * len(response_recency) +
[exploration_score] * len(response_exploration) +
[random_recent_score] * len(response_random_recent))
combined_feed_with_weights = list(zip(combined_feed, combined_weights))

# for debugging

seen = {}
for item, weight in combined_feed_with_weights:
identifier = f"{item['post_id']}_{item['canister_id']}"
if identifier not in seen or seen[identifier][1] < weight:
seen[identifier] = (item, weight)


unique_combined_feed_with_weights = list(seen.values())
combined_feed, combined_weights = zip(*unique_combined_feed_with_weights)


sampled_feed = random.choices(combined_feed, weights=combined_weights, k=num_results)

# for debugging
_LOGGER.warning(f"Length of returned feed: {len(sampled_feed)}")
exploitation_count = sum(1 for item in sampled_feed if item in response_exploitation)
recency_count = sum(1 for item in sampled_feed if item in response_recency)
Expand Down

0 comments on commit 5b4f6ee

Please sign in to comment.