Skip to content

Commit

Permalink
Optimize inference code
Browse files Browse the repository at this point in the history
  • Loading branch information
tqtg committed Dec 10, 2024
1 parent 9241a34 commit 08d25cb
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions tutorials/model_ensembling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -883,39 +883,6 @@
"### 5.1 Preparing the Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "553f4f32",
"metadata": {},
"outputs": [],
"source": [
"# rank_df = pd.DataFrame({\n",
"# \"user_idx\": all_df[\"user_idx\"],\n",
"# \"item_idx\": all_df[\"item_idx\"],\n",
"# })\n",
"\n",
"# total_items = train_set.num_items # 1651 items\n",
"\n",
"# models_to_calculate = [bpr_model, wmf_model, wmf_model_123, wmf_model_456, wmf_model_789, wmf_model_888, wmf_model_999, wmf_model_k20, wmf_model_k30, wmf_model_k40, wmf_model_k50]\n",
"\n",
"# # Calculate points for each model using the Borda count process.\n",
"# # Take note that points should be calculated on a per user basis.\n",
"# for model in tqdm(models_to_calculate):\n",
"# name = model.name\n",
"# rank_df[name + \"_score\"] = rank_df.apply(lambda row: model.score(int(row['user_idx']), int(row['item_idx'])), axis=1)\n",
"# point_list = [] # This list will be added into the dataframe later\n",
"\n",
"# # Calculate points for each user\n",
"# for user_idx in range(train_set.num_users):\n",
"# sub_rank_df = rank_df[rank_df[\"user_idx\"] == user_idx].copy() # get all items for a user\n",
"# sub_rank_df.loc[:, name + \"_rank\"] = sub_rank_df[name + \"_score\"].rank(ascending=False).astype(int) # Rank items\n",
"# sub_rank_df.loc[:, name + \"_points\"] = total_items - sub_rank_df[name + \"_rank\"] # Calculate points\n",
"# point_list.extend(sub_rank_df[name + \"_points\"].values.tolist()) # Add points to the list\n",
" \n",
"# rank_df[name + \"_points\"] = point_list\n"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 08d25cb

Please sign in to comment.