Skip to content

Commit 7d3dc63

Browse files
fixes merging different length recommended lists
1 parent 32ab972 commit 7d3dc63

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

python-recipes/recommendation-systems/collaborative_filtering.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@
14731473
},
14741474
{
14751475
"cell_type": "code",
1476-
"execution_count": 18,
1476+
"execution_count": null,
14771477
"metadata": {},
14781478
"outputs": [],
14791479
"source": [
@@ -1517,14 +1517,14 @@
15171517
"\n",
15181518
"top_picks_for_you = get_unique_recommendations(user_id=user_id, num_results=5) # general SVD results, no filter\n",
15191519
"block_buster_hits = get_unique_recommendations(user_id=user_id, filters=block_buster_filter, num_results=5)\n",
1520-
"classics = get_unique_recommendations(user_id=user_id, filters=classics_filter, num_results=5)\n",
1520+
"classic_movies = get_unique_recommendations(user_id=user_id, filters=classics_filter, num_results=5)\n",
15211521
"whats_popular = get_unique_recommendations(user_id=user_id, filters=popular_filter, num_results=5)\n",
15221522
"indie_hits = get_unique_recommendations(user_id=user_id, filters=indie_filter, num_results=5)"
15231523
]
15241524
},
15251525
{
15261526
"cell_type": "code",
1527-
"execution_count": 19,
1527+
"execution_count": null,
15281528
"metadata": {
15291529
"vscode": {
15301530
"languageId": "ruby"
@@ -1627,13 +1627,13 @@
16271627
],
16281628
"source": [
16291629
"# put all these titles into a single pandas dataframe , where each column is one category\n",
1630-
"all_recommendations = pd.DataFrame(columns=[\"top picks\", \"block busters\", \"classics\", \"what's popular\", \"indie hits\"])\n",
1631-
"all_recommendations[\"top picks\"] = [m[0] for m in top_picks_for_you]\n",
1632-
"all_recommendations[\"block busters\"] = [m[0] for m in block_buster_hits]\n",
1633-
"all_recommendations[\"classics\"] = [m[0] for m in classics]\n",
1634-
"all_recommendations[\"what's popular\"] = [m[0] for m in whats_popular]\n",
1635-
"all_recommendations[\"indie hits\"] = [m[0] for m in indie_hits]\n",
1630+
"top_picks = pd.DataFrame({\"top picks\":[m[0] for m in top_picks_for_you]})\n",
1631+
"block_busters = pd.DataFrame({\"block busters\": [m[0] for m in block_buster_hits]})\n",
1632+
"classics = pd.DataFrame({\"classics\": [m[0] for m in classic_movies]})\n",
1633+
"popular = pd.DataFrame({\"what's popular\": [m[0] for m in whats_popular]})\n",
1634+
"indies = pd.DataFrame({\"indie hits\": [m[0] for m in indie_hits]})\n",
16361635
"\n",
1636+
"all_recommendations = pd.concat([top_picks, block_busters, classics, popular, indies], axis=1)\n",
16371637
"all_recommendations.head()"
16381638
]
16391639
},

0 commit comments

Comments
 (0)