Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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")
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