Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanmidevacc/2fee13ae7c7770c564633cd25ca39134 to your computer and use it in GitHub Desktop.
Save jeanmidevacc/2fee13ae7c7770c564633cd25ca39134 to your computer and use it in GitHub Desktop.
for idx, row in dfp_archetypes.iterrows():
print("ARCHETYPE:", row["userid"])
inventory_positive = dfp_inventory_positive.loc[row["userid"]]
# Get the candidates
buffer = []
for contentid in inventory_positive:
closest_contentids = get_closest_neighbors(model_retriever_items, contentid, 10, type_="item")
buffer.extend(closest_contentids)
sp_count_contentids = pd.Series(dict(Counter(buffer))).sort_values(ascending=False)
candidates = sp_count_contentids.index.tolist()
dfp_items_candidates = dfp_items[dfp_items["contentid"].isin(candidates)]
# Build the recommendations
inventory = dfp_inventory.loc[row["userid"]]
dfp_recommendations = build_recommendations(model_ranker, row["userid"], inventory, dfp_items_candidates)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment