Created
March 15, 2022 12:16
-
-
Save jeanmidevacc/2fee13ae7c7770c564633cd25ca39134 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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