Skip to content

Commit

Permalink
Clear some outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-rliu committed Feb 4, 2025
1 parent f5eced6 commit 7f2360c
Showing 1 changed file with 34 additions and 214 deletions.
248 changes: 34 additions & 214 deletions notebooks/demo/nx_cugraph_jaccard_movie_recommender.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 44,
"id": "c3ad08a2-3f65-48ad-b43b-bb7ed767773e",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -472,7 +472,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 45,
"id": "eff63f64-2ee9-495c-856e-5278baa94d71",
"metadata": {},
"outputs": [
Expand All @@ -481,18 +481,18 @@
"output_type": "stream",
"text": [
"movies similar to Mulan (1998):\n",
"movieId=1566,\tHercules (1997)\n",
"movieId=2687,\tTarzan (1999)\n",
"movieId=4016,\t\"Emperor's New Groove, The (2000)\"\n",
"movieId=2081,\t\"Little Mermaid, The (1989)\"\n",
"movieId=5444,\tLilo & Stitch (2002)\n",
"movieId=2078,\t\"Jungle Book, The (1967)\"\n",
"movieId=2355,\t\"Bug's Life, A (1998)\"\n",
"movieId=81847,\tTangled (2010)\n",
"movieId=3114,\tToy Story 2 (1999)\n",
"movieId=2096,\tSleeping Beauty (1959)\n",
"CPU times: user 180 ms, sys: 15.6 ms, total: 196 ms\n",
"Wall time: 194 ms\n"
"movieId=np.int32(1566),\tHercules (1997)\n",
"movieId=np.int32(2687),\tTarzan (1999)\n",
"movieId=np.int32(4016),\t\"Emperor's New Groove, The (2000)\"\n",
"movieId=np.int32(2081),\t\"Little Mermaid, The (1989)\"\n",
"movieId=np.int32(5444),\tLilo & Stitch (2002)\n",
"movieId=np.int32(2078),\t\"Jungle Book, The (1967)\"\n",
"movieId=np.int32(2355),\t\"Bug's Life, A (1998)\"\n",
"movieId=np.int32(81847),\tTangled (2010)\n",
"movieId=np.int32(3114),\tToy Story 2 (1999)\n",
"movieId=np.int32(2096),\tSleeping Beauty (1959)\n",
"CPU times: user 1min 9s, sys: 324 ms, total: 1min 9s\n",
"Wall time: 1min 9s\n"
]
}
],
Expand All @@ -508,69 +508,29 @@
"source": [
"The `nx.config` confguration namespace can also be used to configure which backend(s) NetworkX will use. This is another option when access to the NetworkX function is not available to pass a kwarg to, as is the case with our helper function. Keep in mind that the `backend=` kwarg will override this setting.\n",
"\n",
"Let's compare the performance of using the cuGraph backend to running with the default NetworkX implementation."
"Try running the following cells yourself to compare the difference in performance by using the cuGraph backend and the default NetworkX implementation."
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"id": "36426fa1-b4ea-4762-bde7-8f2a18886184",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to Mulan (1998):\n",
"movieId=np.int32(1566),\tHercules (1997)\n",
"movieId=np.int32(2687),\tTarzan (1999)\n",
"movieId=np.int32(4016),\t\"Emperor's New Groove, The (2000)\"\n",
"movieId=np.int32(2081),\t\"Little Mermaid, The (1989)\"\n",
"movieId=np.int32(5444),\tLilo & Stitch (2002)\n",
"movieId=np.int32(2078),\t\"Jungle Book, The (1967)\"\n",
"movieId=np.int32(2355),\t\"Bug's Life, A (1998)\"\n",
"movieId=np.int32(81847),\tTangled (2010)\n",
"movieId=np.int32(3114),\tToy Story 2 (1999)\n",
"movieId=np.int32(2096),\tSleeping Beauty (1959)\n",
"CPU times: user 1min 4s, sys: 116 ms, total: 1min 5s\n",
"Wall time: 1min 5s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"current_priority = nx.config.backend_priority\n",
"nx.config.backend_priority=[\"networkx\"]\n",
"nx.config.backend_priority=[\"cugraph\"] # select between 'networkx' and 'cugraph'\n",
"print_similar_movies(highest_rated_movie)\n",
"nx.config.backend_priority = current_priority"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"id": "c296392e-0e60-4338-b602-2945c9fe0b33",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to 101 Dalmatians (1996):\n",
"movieId=np.int32(2085),\t101 Dalmatians (One Hundred and One Dalmatians) (1961)\n",
"movieId=np.int32(783),\t\"Hunchback of Notre Dame, The (1996)\"\n",
"movieId=np.int32(837),\tMatilda (1996)\n",
"movieId=np.int32(673),\tSpace Jam (1996)\n",
"movieId=np.int32(1022),\tCinderella (1950)\n",
"movieId=np.int32(1029),\tDumbo (1941)\n",
"movieId=np.int32(2018),\tBambi (1942)\n",
"movieId=np.int32(2080),\tLady and the Tramp (1955)\n",
"movieId=np.int32(1032),\tAlice in Wonderland (1951)\n",
"movieId=np.int32(661),\tJames and the Giant Peach (1996)\n",
"CPU times: user 46.5 s, sys: 172 ms, total: 46.7 s\n",
"Wall time: 46.7 s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 1367: \"101 Dalmatians (1996)\"\n",
Expand All @@ -579,30 +539,10 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"id": "e4b6a0f0-14de-47e1-8f7f-0a211178c509",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to Star Wars: Episode V - The Empire Strikes Back (1980):\n",
"movieId=np.int32(260),\tStar Wars: Episode IV - A New Hope (1977)\n",
"movieId=np.int32(1210),\tStar Wars: Episode VI - Return of the Jedi (1983)\n",
"movieId=np.int32(1198),\tRaiders of the Lost Ark (Indiana Jones and the Raiders of the Lost Ark) (1981)\n",
"movieId=np.int32(2571),\t\"Matrix, The (1999)\"\n",
"movieId=np.int32(1291),\tIndiana Jones and the Last Crusade (1989)\n",
"movieId=np.int32(1270),\tBack to the Future (1985)\n",
"movieId=np.int32(1240),\t\"Terminator, The (1984)\"\n",
"movieId=np.int32(4993),\t\"Lord of the Rings: The Fellowship of the Ring, The (2001)\"\n",
"movieId=np.int32(1214),\tAlien (1979)\n",
"movieId=np.int32(5952),\t\"Lord of the Rings: The Two Towers, The (2002)\"\n",
"CPU times: user 4min 22s, sys: 309 ms, total: 4min 22s\n",
"Wall time: 4min 22s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 1196: \"Star Wars: Episode V - The Empire Strikes Back (1980)\"\n",
Expand All @@ -611,30 +551,10 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"id": "2911e5da-783b-4b48-8093-30295edc77a7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to Tron (1982):\n",
"movieId=np.int32(2021),\tDune (1984)\n",
"movieId=np.int32(2985),\tRoboCop (1987)\n",
"movieId=np.int32(1374),\tStar Trek II: The Wrath of Khan (1982)\n",
"movieId=np.int32(2968),\tTime Bandits (1981)\n",
"movieId=np.int32(2193),\tWillow (1988)\n",
"movieId=np.int32(2640),\tSuperman (1978)\n",
"movieId=np.int32(2140),\t\"Dark Crystal, The (1982)\"\n",
"movieId=np.int32(1127),\t\"Abyss, The (1989)\"\n",
"movieId=np.int32(1375),\tStar Trek III: The Search for Spock (1984)\n",
"movieId=np.int32(3033),\tSpaceballs (1987)\n",
"CPU times: user 56.5 s, sys: 378 ms, total: 56.8 s\n",
"Wall time: 56.5 s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 2105: \"Tron (1982)\"\n",
Expand All @@ -643,30 +563,10 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"id": "2dab0a8e-a77b-4e7a-9dae-d9282a426b9b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to Donnie Darko (2001):\n",
"movieId=np.int32(7361),\tEternal Sunshine of the Spotless Mind (2004)\n",
"movieId=np.int32(4226),\tMemento (2000)\n",
"movieId=np.int32(3949),\tRequiem for a Dream (2000)\n",
"movieId=np.int32(6874),\tKill Bill: Vol. 1 (2003)\n",
"movieId=np.int32(7438),\tKill Bill: Vol. 2 (2004)\n",
"movieId=np.int32(4011),\tSnatch (2000)\n",
"movieId=np.int32(2959),\tFight Club (1999)\n",
"movieId=np.int32(2329),\tAmerican History X (1998)\n",
"movieId=np.int32(48394),\t\"Pan's Labyrinth (Laberinto del fauno, El) (2006)\"\n",
"movieId=np.int32(32587),\tSin City (2005)\n",
"CPU times: user 2min 36s, sys: 167 ms, total: 2min 37s\n",
"Wall time: 2min 37s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 4878: \"Donnie Darko (2001)\"\n",
Expand All @@ -675,30 +575,10 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"id": "d20e20f7-8302-4f5d-94bf-909aa3715728",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to Forbidden Planet (1956):\n",
"movieId=np.int32(1253),\t\"Day the Earth Stood Still, The (1951)\"\n",
"movieId=np.int32(2664),\tInvasion of the Body Snatchers (1956)\n",
"movieId=np.int32(2662),\t\"War of the Worlds, The (1953)\"\n",
"movieId=np.int32(2009),\tSoylent Green (1973)\n",
"movieId=np.int32(2527),\tWestworld (1973)\n",
"movieId=np.int32(1334),\t\"Blob, The (1958)\"\n",
"movieId=np.int32(2528),\tLogan's Run (1976)\n",
"movieId=np.int32(1019),\t\"20,000 Leagues Under the Sea (1954)\"\n",
"movieId=np.int32(2287),\tThem! (1954)\n",
"movieId=np.int32(3959),\t\"Time Machine, The (1960)\"\n",
"CPU times: user 22.2 s, sys: 152 ms, total: 22.4 s\n",
"Wall time: 22.4 s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 1301: \"Forbidden Planet (1956)\"\n",
Expand All @@ -707,30 +587,10 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"id": "cccd169e-ee6e-4734-9f8d-7f3fd7662fd4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to \"Secret of NIMH, The (1982)\":\n",
"movieId=np.int32(2141),\t\"American Tail, An (1986)\"\n",
"movieId=np.int32(2090),\t\"Rescuers, The (1977)\"\n",
"movieId=np.int32(2137),\tCharlotte's Web (1973)\n",
"movieId=np.int32(3034),\tRobin Hood (1973)\n",
"movieId=np.int32(2140),\t\"Dark Crystal, The (1982)\"\n",
"movieId=np.int32(1025),\t\"Sword in the Stone, The (1963)\"\n",
"movieId=np.int32(1967),\tLabyrinth (1986)\n",
"movieId=np.int32(2161),\t\"NeverEnding Story, The (1984)\"\n",
"movieId=np.int32(2096),\tSleeping Beauty (1959)\n",
"movieId=np.int32(2087),\tPeter Pan (1953)\n",
"CPU times: user 37.9 s, sys: 140 ms, total: 38 s\n",
"Wall time: 38 s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 2139: \"\"Secret of NIMH, The (1982)\"\"\n",
Expand All @@ -739,30 +599,10 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": null,
"id": "fd569826-109b-4e3a-92a2-6c3cfef659dd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to Thor: The Dark World (2013):\n",
"movieId=np.int32(86332),\tThor (2011)\n",
"movieId=np.int32(102125),\tIron Man 3 (2013)\n",
"movieId=np.int32(122892),\tAvengers: Age of Ultron (2015)\n",
"movieId=np.int32(110102),\tCaptain America: The Winter Soldier (2014)\n",
"movieId=np.int32(88140),\tCaptain America: The First Avenger (2011)\n",
"movieId=np.int32(122900),\tAnt-Man (2015)\n",
"movieId=np.int32(103042),\tMan of Steel (2013)\n",
"movieId=np.int32(122920),\tCaptain America: Civil War (2016)\n",
"movieId=np.int32(95510),\t\"Amazing Spider-Man, The (2012)\"\n",
"movieId=np.int32(77561),\tIron Man 2 (2010)\n",
"CPU times: user 40.6 s, sys: 83.8 ms, total: 40.7 s\n",
"Wall time: 40.7 s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 106072: \"Thor: The Dark World (2013)\"\n",
Expand All @@ -771,30 +611,10 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"id": "be944ff6-40b1-4f94-be77-1a1d52a5ffaf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"movies similar to \"Shawshank Redemption, The (1994)\":\n",
"movieId=np.int32(296),\tPulp Fiction (1994)\n",
"movieId=np.int32(593),\t\"Silence of the Lambs, The (1991)\"\n",
"movieId=np.int32(356),\tForrest Gump (1994)\n",
"movieId=np.int32(527),\tSchindler's List (1993)\n",
"movieId=np.int32(2571),\t\"Matrix, The (1999)\"\n",
"movieId=np.int32(50),\t\"Usual Suspects, The (1995)\"\n",
"movieId=np.int32(2959),\tFight Club (1999)\n",
"movieId=np.int32(47),\tSeven (a.k.a. Se7en) (1995)\n",
"movieId=np.int32(858),\t\"Godfather, The (1972)\"\n",
"movieId=np.int32(110),\tBraveheart (1995)\n",
"CPU times: user 6min 46s, sys: 367 ms, total: 6min 47s\n",
"Wall time: 6min 47s\n"
]
}
],
"outputs": [],
"source": [
"%%time\n",
"# 318: \"\"Shawshank Redemption, The (1994)\"\"\n",
Expand Down

0 comments on commit 7f2360c

Please sign in to comment.