diff --git "a/movie_recommender_System.ipynb" "b/movie_recommender_System.ipynb" new file mode 100644--- /dev/null +++ "b/movie_recommender_System.ipynb" @@ -0,0 +1,2232 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 43, + "id": "b6072dbd-06c1-40ff-b8ac-0f04cc80363d", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "1ca1894b-b383-4f9a-9919-d4811530cc3a", + "metadata": {}, + "outputs": [], + "source": [ + "movies = pd.read_csv('tmdb_5000_movies.csv')\n", + "credits = pd.read_csv('tmdb_5000_credits.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "53b5f3ef-2104-44a5-8af1-1af9e25ca00e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
budgetgenreshomepageidkeywordsoriginal_languageoriginal_titleoverviewpopularityproduction_companiesproduction_countriesrelease_daterevenueruntimespoken_languagesstatustaglinetitlevote_averagevote_count
0237000000[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...http://www.avatarmovie.com/19995[{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":...enAvatarIn the 22nd century, a paraplegic Marine is di...150.437577[{\"name\": \"Ingenious Film Partners\", \"id\": 289...[{\"iso_3166_1\": \"US\", \"name\": \"United States o...2009-12-102787965087162.0[{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso...ReleasedEnter the World of Pandora.Avatar7.211800
\n", + "
" + ], + "text/plain": [ + " budget genres \\\n", + "0 237000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n", + "\n", + " homepage id \\\n", + "0 http://www.avatarmovie.com/ 19995 \n", + "\n", + " keywords original_language \\\n", + "0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... en \n", + "\n", + " original_title overview \\\n", + "0 Avatar In the 22nd century, a paraplegic Marine is di... \n", + "\n", + " popularity production_companies \\\n", + "0 150.437577 [{\"name\": \"Ingenious Film Partners\", \"id\": 289... \n", + "\n", + " production_countries release_date revenue \\\n", + "0 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2009-12-10 2787965087 \n", + "\n", + " runtime spoken_languages status \\\n", + "0 162.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... Released \n", + "\n", + " tagline title vote_average vote_count \n", + "0 Enter the World of Pandora. Avatar 7.2 11800 " + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(1)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "ba18255f-b5fa-4e15-ad47-96fe580a9415", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitlecastcrew
019995Avatar[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"...[{\"credit_id\": \"52fe48009251416c750aca23\", \"de...
\n", + "
" + ], + "text/plain": [ + " movie_id title cast \\\n", + "0 19995 Avatar [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n", + "\n", + " crew \n", + "0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... " + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "credits.head(1)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "c0e221cc-6568-4132-bf55-1c5d243d8fcd", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"credit_id\": \"5602a8a7c3a3685532001c9a\", \"gender\": 2, \"id\": 65731, \"name\": \"Sam Worthington\", \"order\": 0}, {\"cast_id\": 3, \"character\": \"Neytiri\", \"credit_id\": \"52fe48009251416c750ac9cb\", \"gender\": 1, \"id\": 8691, \"name\": \"Zoe Saldana\", \"order\": 1}, {\"cast_id\": 25, \"character\": \"Dr. Grace Augustine\", \"credit_id\": \"52fe48009251416c750aca39\", \"gender\": 1, \"id\": 10205, \"name\": \"Sigourney Weaver\", \"order\": 2}, {\"cast_id\": 4, \"character\": \"Col. Quaritch\", \"credit_id\": \"52fe48009251416c750ac9cf\", \"gender\": 2, \"id\": 32747, \"name\": \"Stephen Lang\", \"order\": 3}, {\"cast_id\": 5, \"character\": \"Trudy Chacon\", \"credit_id\": \"52fe48009251416c750ac9d3\", \"gender\": 1, \"id\": 17647, \"name\": \"Michelle Rodriguez\", \"order\": 4}, {\"cast_id\": 8, \"character\": \"Selfridge\", \"credit_id\": \"52fe48009251416c750ac9e1\", \"gender\": 2, \"id\": 1771, \"name\": \"Giovanni Ribisi\", \"order\": 5}, {\"cast_id\": 7, \"character\": \"Norm Spellman\", \"credit_id\": \"52fe48009251416c750ac9dd\", \"gender\": 2, \"id\": 59231, \"name\": \"Joel David Moore\", \"order\": 6}, {\"cast_id\": 9, \"character\": \"Moat\", \"credit_id\": \"52fe48009251416c750ac9e5\", \"gender\": 1, \"id\": 30485, \"name\": \"CCH Pounder\", \"order\": 7}, {\"cast_id\": 11, \"character\": \"Eytukan\", \"credit_id\": \"52fe48009251416c750ac9ed\", \"gender\": 2, \"id\": 15853, \"name\": \"Wes Studi\", \"order\": 8}, {\"cast_id\": 10, \"character\": \"Tsu\\'Tey\", \"credit_id\": \"52fe48009251416c750ac9e9\", \"gender\": 2, \"id\": 10964, \"name\": \"Laz Alonso\", \"order\": 9}, {\"cast_id\": 12, \"character\": \"Dr. Max Patel\", \"credit_id\": \"52fe48009251416c750ac9f1\", \"gender\": 2, \"id\": 95697, \"name\": \"Dileep Rao\", \"order\": 10}, {\"cast_id\": 13, \"character\": \"Lyle Wainfleet\", \"credit_id\": \"52fe48009251416c750ac9f5\", \"gender\": 2, \"id\": 98215, \"name\": \"Matt Gerald\", \"order\": 11}, {\"cast_id\": 32, \"character\": \"Private Fike\", \"credit_id\": \"52fe48009251416c750aca5b\", \"gender\": 2, \"id\": 154153, \"name\": \"Sean Anthony Moran\", \"order\": 12}, {\"cast_id\": 33, \"character\": \"Cryo Vault Med Tech\", \"credit_id\": \"52fe48009251416c750aca5f\", \"gender\": 2, \"id\": 397312, \"name\": \"Jason Whyte\", \"order\": 13}, {\"cast_id\": 34, \"character\": \"Venture Star Crew Chief\", \"credit_id\": \"52fe48009251416c750aca63\", \"gender\": 2, \"id\": 42317, \"name\": \"Scott Lawrence\", \"order\": 14}, {\"cast_id\": 35, \"character\": \"Lock Up Trooper\", \"credit_id\": \"52fe48009251416c750aca67\", \"gender\": 2, \"id\": 986734, \"name\": \"Kelly Kilgour\", \"order\": 15}, {\"cast_id\": 36, \"character\": \"Shuttle Pilot\", \"credit_id\": \"52fe48009251416c750aca6b\", \"gender\": 0, \"id\": 1207227, \"name\": \"James Patrick Pitt\", \"order\": 16}, {\"cast_id\": 37, \"character\": \"Shuttle Co-Pilot\", \"credit_id\": \"52fe48009251416c750aca6f\", \"gender\": 0, \"id\": 1180936, \"name\": \"Sean Patrick Murphy\", \"order\": 17}, {\"cast_id\": 38, \"character\": \"Shuttle Crew Chief\", \"credit_id\": \"52fe48009251416c750aca73\", \"gender\": 2, \"id\": 1019578, \"name\": \"Peter Dillon\", \"order\": 18}, {\"cast_id\": 39, \"character\": \"Tractor Operator / Troupe\", \"credit_id\": \"52fe48009251416c750aca77\", \"gender\": 0, \"id\": 91443, \"name\": \"Kevin Dorman\", \"order\": 19}, {\"cast_id\": 40, \"character\": \"Dragon Gunship Pilot\", \"credit_id\": \"52fe48009251416c750aca7b\", \"gender\": 2, \"id\": 173391, \"name\": \"Kelson Henderson\", \"order\": 20}, {\"cast_id\": 41, \"character\": \"Dragon Gunship Gunner\", \"credit_id\": \"52fe48009251416c750aca7f\", \"gender\": 0, \"id\": 1207236, \"name\": \"David Van Horn\", \"order\": 21}, {\"cast_id\": 42, \"character\": \"Dragon Gunship Navigator\", \"credit_id\": \"52fe48009251416c750aca83\", \"gender\": 0, \"id\": 215913, \"name\": \"Jacob Tomuri\", \"order\": 22}, {\"cast_id\": 43, \"character\": \"Suit #1\", \"credit_id\": \"52fe48009251416c750aca87\", \"gender\": 0, \"id\": 143206, \"name\": \"Michael Blain-Rozgay\", \"order\": 23}, {\"cast_id\": 44, \"character\": \"Suit #2\", \"credit_id\": \"52fe48009251416c750aca8b\", \"gender\": 2, \"id\": 169676, \"name\": \"Jon Curry\", \"order\": 24}, {\"cast_id\": 46, \"character\": \"Ambient Room Tech\", \"credit_id\": \"52fe48009251416c750aca8f\", \"gender\": 0, \"id\": 1048610, \"name\": \"Luke Hawker\", \"order\": 25}, {\"cast_id\": 47, \"character\": \"Ambient Room Tech / Troupe\", \"credit_id\": \"52fe48009251416c750aca93\", \"gender\": 0, \"id\": 42288, \"name\": \"Woody Schultz\", \"order\": 26}, {\"cast_id\": 48, \"character\": \"Horse Clan Leader\", \"credit_id\": \"52fe48009251416c750aca97\", \"gender\": 2, \"id\": 68278, \"name\": \"Peter Mensah\", \"order\": 27}, {\"cast_id\": 49, \"character\": \"Link Room Tech\", \"credit_id\": \"52fe48009251416c750aca9b\", \"gender\": 0, \"id\": 1207247, \"name\": \"Sonia Yee\", \"order\": 28}, {\"cast_id\": 50, \"character\": \"Basketball Avatar / Troupe\", \"credit_id\": \"52fe48009251416c750aca9f\", \"gender\": 1, \"id\": 1207248, \"name\": \"Jahnel Curfman\", \"order\": 29}, {\"cast_id\": 51, \"character\": \"Basketball Avatar\", \"credit_id\": \"52fe48009251416c750acaa3\", \"gender\": 0, \"id\": 89714, \"name\": \"Ilram Choi\", \"order\": 30}, {\"cast_id\": 52, \"character\": \"Na\\'vi Child\", \"credit_id\": \"52fe48009251416c750acaa7\", \"gender\": 0, \"id\": 1207249, \"name\": \"Kyla Warren\", \"order\": 31}, {\"cast_id\": 53, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acaab\", \"gender\": 0, \"id\": 1207250, \"name\": \"Lisa Roumain\", \"order\": 32}, {\"cast_id\": 54, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acaaf\", \"gender\": 1, \"id\": 83105, \"name\": \"Debra Wilson\", \"order\": 33}, {\"cast_id\": 57, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acabb\", \"gender\": 0, \"id\": 1207253, \"name\": \"Chris Mala\", \"order\": 34}, {\"cast_id\": 55, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acab3\", \"gender\": 0, \"id\": 1207251, \"name\": \"Taylor Kibby\", \"order\": 35}, {\"cast_id\": 56, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acab7\", \"gender\": 0, \"id\": 1207252, \"name\": \"Jodie Landau\", \"order\": 36}, {\"cast_id\": 58, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acabf\", \"gender\": 0, \"id\": 1207254, \"name\": \"Julie Lamm\", \"order\": 37}, {\"cast_id\": 59, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acac3\", \"gender\": 0, \"id\": 1207257, \"name\": \"Cullen B. Madden\", \"order\": 38}, {\"cast_id\": 60, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acac7\", \"gender\": 0, \"id\": 1207259, \"name\": \"Joseph Brady Madden\", \"order\": 39}, {\"cast_id\": 61, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acacb\", \"gender\": 0, \"id\": 1207262, \"name\": \"Frankie Torres\", \"order\": 40}, {\"cast_id\": 62, \"character\": \"Troupe\", \"credit_id\": \"52fe48009251416c750acacf\", \"gender\": 1, \"id\": 1158600, \"name\": \"Austin Wilson\", \"order\": 41}, {\"cast_id\": 63, \"character\": \"Troupe\", \"credit_id\": \"52fe48019251416c750acad3\", \"gender\": 1, \"id\": 983705, \"name\": \"Sara Wilson\", \"order\": 42}, {\"cast_id\": 64, \"character\": \"Troupe\", \"credit_id\": \"52fe48019251416c750acad7\", \"gender\": 0, \"id\": 1207263, \"name\": \"Tamica Washington-Miller\", \"order\": 43}, {\"cast_id\": 65, \"character\": \"Op Center Staff\", \"credit_id\": \"52fe48019251416c750acadb\", \"gender\": 1, \"id\": 1145098, \"name\": \"Lucy Briant\", \"order\": 44}, {\"cast_id\": 66, \"character\": \"Op Center Staff\", \"credit_id\": \"52fe48019251416c750acadf\", \"gender\": 2, \"id\": 33305, \"name\": \"Nathan Meister\", \"order\": 45}, {\"cast_id\": 67, \"character\": \"Op Center Staff\", \"credit_id\": \"52fe48019251416c750acae3\", \"gender\": 0, \"id\": 1207264, \"name\": \"Gerry Blair\", \"order\": 46}, {\"cast_id\": 68, \"character\": \"Op Center Staff\", \"credit_id\": \"52fe48019251416c750acae7\", \"gender\": 2, \"id\": 33311, \"name\": \"Matthew Chamberlain\", \"order\": 47}, {\"cast_id\": 69, \"character\": \"Op Center Staff\", \"credit_id\": \"52fe48019251416c750acaeb\", \"gender\": 0, \"id\": 1207265, \"name\": \"Paul Yates\", \"order\": 48}, {\"cast_id\": 70, \"character\": \"Op Center Duty Officer\", \"credit_id\": \"52fe48019251416c750acaef\", \"gender\": 0, \"id\": 1207266, \"name\": \"Wray Wilson\", \"order\": 49}, {\"cast_id\": 71, \"character\": \"Op Center Staff\", \"credit_id\": \"52fe48019251416c750acaf3\", \"gender\": 2, \"id\": 54492, \"name\": \"James Gaylyn\", \"order\": 50}, {\"cast_id\": 72, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acaf7\", \"gender\": 0, \"id\": 1207267, \"name\": \"Melvin Leno Clark III\", \"order\": 51}, {\"cast_id\": 73, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acafb\", \"gender\": 0, \"id\": 1207268, \"name\": \"Carvon Futrell\", \"order\": 52}, {\"cast_id\": 74, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acaff\", \"gender\": 0, \"id\": 1207269, \"name\": \"Brandon Jelkes\", \"order\": 53}, {\"cast_id\": 75, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acb03\", \"gender\": 0, \"id\": 1207270, \"name\": \"Micah Moch\", \"order\": 54}, {\"cast_id\": 76, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acb07\", \"gender\": 0, \"id\": 1207271, \"name\": \"Hanniyah Muhammad\", \"order\": 55}, {\"cast_id\": 77, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acb0b\", \"gender\": 0, \"id\": 1207272, \"name\": \"Christopher Nolen\", \"order\": 56}, {\"cast_id\": 78, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acb0f\", \"gender\": 0, \"id\": 1207273, \"name\": \"Christa Oliver\", \"order\": 57}, {\"cast_id\": 79, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acb13\", \"gender\": 0, \"id\": 1207274, \"name\": \"April Marie Thomas\", \"order\": 58}, {\"cast_id\": 80, \"character\": \"Dancer\", \"credit_id\": \"52fe48019251416c750acb17\", \"gender\": 0, \"id\": 1207275, \"name\": \"Bravita A. Threatt\", \"order\": 59}, {\"cast_id\": 81, \"character\": \"Mining Chief (uncredited)\", \"credit_id\": \"52fe48019251416c750acb1b\", \"gender\": 0, \"id\": 1207276, \"name\": \"Colin Bleasdale\", \"order\": 60}, {\"cast_id\": 82, \"character\": \"Veteran Miner (uncredited)\", \"credit_id\": \"52fe48019251416c750acb1f\", \"gender\": 0, \"id\": 107969, \"name\": \"Mike Bodnar\", \"order\": 61}, {\"cast_id\": 83, \"character\": \"Richard (uncredited)\", \"credit_id\": \"52fe48019251416c750acb23\", \"gender\": 0, \"id\": 1207278, \"name\": \"Matt Clayton\", \"order\": 62}, {\"cast_id\": 84, \"character\": \"Nav\\'i (uncredited)\", \"credit_id\": \"52fe48019251416c750acb27\", \"gender\": 1, \"id\": 147898, \"name\": \"Nicole Dionne\", \"order\": 63}, {\"cast_id\": 85, \"character\": \"Trooper (uncredited)\", \"credit_id\": \"52fe48019251416c750acb2b\", \"gender\": 0, \"id\": 1207280, \"name\": \"Jamie Harrison\", \"order\": 64}, {\"cast_id\": 86, \"character\": \"Trooper (uncredited)\", \"credit_id\": \"52fe48019251416c750acb2f\", \"gender\": 0, \"id\": 1207281, \"name\": \"Allan Henry\", \"order\": 65}, {\"cast_id\": 87, \"character\": \"Ground Technician (uncredited)\", \"credit_id\": \"52fe48019251416c750acb33\", \"gender\": 2, \"id\": 1207282, \"name\": \"Anthony Ingruber\", \"order\": 66}, {\"cast_id\": 88, \"character\": \"Flight Crew Mechanic (uncredited)\", \"credit_id\": \"52fe48019251416c750acb37\", \"gender\": 0, \"id\": 1207283, \"name\": \"Ashley Jeffery\", \"order\": 67}, {\"cast_id\": 14, \"character\": \"Samson Pilot\", \"credit_id\": \"52fe48009251416c750ac9f9\", \"gender\": 0, \"id\": 98216, \"name\": \"Dean Knowsley\", \"order\": 68}, {\"cast_id\": 89, \"character\": \"Trooper (uncredited)\", \"credit_id\": \"52fe48019251416c750acb3b\", \"gender\": 0, \"id\": 1201399, \"name\": \"Joseph Mika-Hunt\", \"order\": 69}, {\"cast_id\": 90, \"character\": \"Banshee (uncredited)\", \"credit_id\": \"52fe48019251416c750acb3f\", \"gender\": 0, \"id\": 236696, \"name\": \"Terry Notary\", \"order\": 70}, {\"cast_id\": 91, \"character\": \"Soldier (uncredited)\", \"credit_id\": \"52fe48019251416c750acb43\", \"gender\": 0, \"id\": 1207287, \"name\": \"Kai Pantano\", \"order\": 71}, {\"cast_id\": 92, \"character\": \"Blast Technician (uncredited)\", \"credit_id\": \"52fe48019251416c750acb47\", \"gender\": 0, \"id\": 1207288, \"name\": \"Logan Pithyou\", \"order\": 72}, {\"cast_id\": 93, \"character\": \"Vindum Raah (uncredited)\", \"credit_id\": \"52fe48019251416c750acb4b\", \"gender\": 0, \"id\": 1207289, \"name\": \"Stuart Pollock\", \"order\": 73}, {\"cast_id\": 94, \"character\": \"Hero (uncredited)\", \"credit_id\": \"52fe48019251416c750acb4f\", \"gender\": 0, \"id\": 584868, \"name\": \"Raja\", \"order\": 74}, {\"cast_id\": 95, \"character\": \"Ops Centreworker (uncredited)\", \"credit_id\": \"52fe48019251416c750acb53\", \"gender\": 0, \"id\": 1207290, \"name\": \"Gareth Ruck\", \"order\": 75}, {\"cast_id\": 96, \"character\": \"Engineer (uncredited)\", \"credit_id\": \"52fe48019251416c750acb57\", \"gender\": 0, \"id\": 1062463, \"name\": \"Rhian Sheehan\", \"order\": 76}, {\"cast_id\": 97, \"character\": \"Col. Quaritch\\'s Mech Suit (uncredited)\", \"credit_id\": \"52fe48019251416c750acb5b\", \"gender\": 0, \"id\": 60656, \"name\": \"T. J. Storm\", \"order\": 77}, {\"cast_id\": 98, \"character\": \"Female Marine (uncredited)\", \"credit_id\": \"52fe48019251416c750acb5f\", \"gender\": 0, \"id\": 1207291, \"name\": \"Jodie Taylor\", \"order\": 78}, {\"cast_id\": 99, \"character\": \"Ikran Clan Leader (uncredited)\", \"credit_id\": \"52fe48019251416c750acb63\", \"gender\": 1, \"id\": 1186027, \"name\": \"Alicia Vela-Bailey\", \"order\": 79}, {\"cast_id\": 100, \"character\": \"Geologist (uncredited)\", \"credit_id\": \"52fe48019251416c750acb67\", \"gender\": 0, \"id\": 1207292, \"name\": \"Richard Whiteside\", \"order\": 80}, {\"cast_id\": 101, \"character\": \"Na\\'vi (uncredited)\", \"credit_id\": \"52fe48019251416c750acb6b\", \"gender\": 0, \"id\": 103259, \"name\": \"Nikie Zambo\", \"order\": 81}, {\"cast_id\": 102, \"character\": \"Ambient Room Tech / Troupe\", \"credit_id\": \"52fe48019251416c750acb6f\", \"gender\": 1, \"id\": 42286, \"name\": \"Julene Renee\", \"order\": 82}]'],\n", + " dtype=object)" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "credits.head(1)['cast'].values" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "7bd04743-21ae-48f1-b128-aa3264217936", + "metadata": {}, + "outputs": [], + "source": [ + "movies= movies.merge(credits, on = 'title')" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "b6b2cf8d-00fe-4d40-a271-48f7e0a04ce1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
budgetgenreshomepageidkeywordsoriginal_languageoriginal_titleoverviewpopularityproduction_companies...runtimespoken_languagesstatustaglinetitlevote_averagevote_countmovie_idcastcrew
0237000000[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...http://www.avatarmovie.com/19995[{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":...enAvatarIn the 22nd century, a paraplegic Marine is di...150.437577[{\"name\": \"Ingenious Film Partners\", \"id\": 289......162.0[{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso...ReleasedEnter the World of Pandora.Avatar7.21180019995[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"...[{\"credit_id\": \"52fe48009251416c750aca23\", \"de...
\n", + "

1 rows × 23 columns

\n", + "
" + ], + "text/plain": [ + " budget genres \\\n", + "0 237000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n", + "\n", + " homepage id \\\n", + "0 http://www.avatarmovie.com/ 19995 \n", + "\n", + " keywords original_language \\\n", + "0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... en \n", + "\n", + " original_title overview \\\n", + "0 Avatar In the 22nd century, a paraplegic Marine is di... \n", + "\n", + " popularity production_companies ... runtime \\\n", + "0 150.437577 [{\"name\": \"Ingenious Film Partners\", \"id\": 289... ... 162.0 \n", + "\n", + " spoken_languages status \\\n", + "0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... Released \n", + "\n", + " tagline title vote_average vote_count movie_id \\\n", + "0 Enter the World of Pandora. Avatar 7.2 11800 19995 \n", + "\n", + " cast \\\n", + "0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n", + "\n", + " crew \n", + "0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n", + "\n", + "[1 rows x 23 columns]" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(1)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "id": "bc4491ed-ab12-4930-a080-8a67e024bcfb", + "metadata": {}, + "outputs": [], + "source": [ + "movies = movies[['movie_id','title','overview','genres','keywords','cast','crew']]" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "6436eee0-514f-4388-99aa-7e89d0dd6601", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "movie_id 0\n", + "title 0\n", + "overview 3\n", + "genres 0\n", + "keywords 0\n", + "cast 0\n", + "crew 0\n", + "dtype: int64" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.isnull().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "id": "cb9ba3d7-16ee-472c-8bce-9a5beb4a83bc", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\vaish\\AppData\\Local\\Temp\\ipykernel_10236\\3024812739.py:1: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " movies.dropna(inplace = True)\n" + ] + } + ], + "source": [ + "movies.dropna(inplace = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "id": "5c1dbada-7262-4502-9de4-27f7e16f000d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "movie_id 0\n", + "title 0\n", + "overview 0\n", + "genres 0\n", + "keywords 0\n", + "cast 0\n", + "crew 0\n", + "dtype: int64" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.isnull().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "id": "519ee0d1-1f9b-478b-8eb5-127972b26cbf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.duplicated().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "id": "8dcee130-7bb8-4cc6-8650-88288cf5a98e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"name\": \"Fantasy\"}, {\"id\": 878, \"name\": \"Science Fiction\"}]'" + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.iloc[0].genres" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "id": "d27e9ba7-cdc2-46fe-94a6-b11a93d9588e", + "metadata": {}, + "outputs": [], + "source": [ + "import ast\n", + "def convert(obj):\n", + " lst = []\n", + " for i in ast.literal_eval(obj):\n", + " lst.append(i['name'])\n", + " return lst" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "id": "a046a3e0-15b6-4072-a3ca-239131264f80", + "metadata": {}, + "outputs": [], + "source": [ + "movies['genres'] = movies['genres'].apply(convert)" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "id": "c9044e55-bff7-4b2d-80e9-74c70a143eb8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitleoverviewgenreskeywordscastcrew
019995AvatarIn the 22nd century, a paraplegic Marine is di...[Action, Adventure, Fantasy, Science Fiction][{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":...[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"...[{\"credit_id\": \"52fe48009251416c750aca23\", \"de...
1285Pirates of the Caribbean: At World's EndCaptain Barbossa, long believed to be dead, ha...[Adventure, Fantasy, Action][{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na...[{\"cast_id\": 4, \"character\": \"Captain Jack Spa...[{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de...
2206647SpectreA cryptic message from Bond’s past sends him o...[Action, Adventure, Crime][{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name...[{\"cast_id\": 1, \"character\": \"James Bond\", \"cr...[{\"credit_id\": \"54805967c3a36829b5002c41\", \"de...
349026The Dark Knight RisesFollowing the death of District Attorney Harve...[Action, Crime, Drama, Thriller][{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,...[{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba...[{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de...
449529John CarterJohn Carter is a war-weary, former military ca...[Action, Adventure, Science Fiction][{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":...[{\"cast_id\": 5, \"character\": \"John Carter\", \"c...[{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " overview \\\n", + "0 In the 22nd century, a paraplegic Marine is di... \n", + "1 Captain Barbossa, long believed to be dead, ha... \n", + "2 A cryptic message from Bond’s past sends him o... \n", + "3 Following the death of District Attorney Harve... \n", + "4 John Carter is a war-weary, former military ca... \n", + "\n", + " genres \\\n", + "0 [Action, Adventure, Fantasy, Science Fiction] \n", + "1 [Adventure, Fantasy, Action] \n", + "2 [Action, Adventure, Crime] \n", + "3 [Action, Crime, Drama, Thriller] \n", + "4 [Action, Adventure, Science Fiction] \n", + "\n", + " keywords \\\n", + "0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... \n", + "1 [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... \n", + "2 [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... \n", + "3 [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... \n", + "4 [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... \n", + "\n", + " cast \\\n", + "0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n", + "1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n", + "2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n", + "3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n", + "4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n", + "\n", + " crew \n", + "0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n", + "1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n", + "2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n", + "3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n", + "4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... " + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "id": "22f4d67e-30d6-4f53-80d4-70b11e4218c9", + "metadata": {}, + "outputs": [], + "source": [ + "movies['keywords'] = movies['keywords'].apply(convert)" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "id": "8add5e94-67b7-4ac5-a33d-c28ac57efb7a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitleoverviewgenreskeywordscastcrew
019995AvatarIn the 22nd century, a paraplegic Marine is di...[Action, Adventure, Fantasy, Science Fiction][culture clash, future, space war, space colon...[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"...[{\"credit_id\": \"52fe48009251416c750aca23\", \"de...
1285Pirates of the Caribbean: At World's EndCaptain Barbossa, long believed to be dead, ha...[Adventure, Fantasy, Action][ocean, drug abuse, exotic island, east india ...[{\"cast_id\": 4, \"character\": \"Captain Jack Spa...[{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de...
2206647SpectreA cryptic message from Bond’s past sends him o...[Action, Adventure, Crime][spy, based on novel, secret agent, sequel, mi...[{\"cast_id\": 1, \"character\": \"James Bond\", \"cr...[{\"credit_id\": \"54805967c3a36829b5002c41\", \"de...
349026The Dark Knight RisesFollowing the death of District Attorney Harve...[Action, Crime, Drama, Thriller][dc comics, crime fighter, terrorist, secret i...[{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba...[{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de...
449529John CarterJohn Carter is a war-weary, former military ca...[Action, Adventure, Science Fiction][based on novel, mars, medallion, space travel...[{\"cast_id\": 5, \"character\": \"John Carter\", \"c...[{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " overview \\\n", + "0 In the 22nd century, a paraplegic Marine is di... \n", + "1 Captain Barbossa, long believed to be dead, ha... \n", + "2 A cryptic message from Bond’s past sends him o... \n", + "3 Following the death of District Attorney Harve... \n", + "4 John Carter is a war-weary, former military ca... \n", + "\n", + " genres \\\n", + "0 [Action, Adventure, Fantasy, Science Fiction] \n", + "1 [Adventure, Fantasy, Action] \n", + "2 [Action, Adventure, Crime] \n", + "3 [Action, Crime, Drama, Thriller] \n", + "4 [Action, Adventure, Science Fiction] \n", + "\n", + " keywords \\\n", + "0 [culture clash, future, space war, space colon... \n", + "1 [ocean, drug abuse, exotic island, east india ... \n", + "2 [spy, based on novel, secret agent, sequel, mi... \n", + "3 [dc comics, crime fighter, terrorist, secret i... \n", + "4 [based on novel, mars, medallion, space travel... \n", + "\n", + " cast \\\n", + "0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n", + "1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n", + "2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n", + "3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n", + "4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n", + "\n", + " crew \n", + "0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n", + "1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n", + "2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n", + "3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n", + "4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... " + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "id": "766b325f-11f8-401a-8140-6452a86a48c6", + "metadata": {}, + "outputs": [], + "source": [ + "import ast\n", + "def convert3(obj):\n", + " lst = []\n", + " counter = 0\n", + " for i in ast.literal_eval(obj):\n", + " if counter!=3:\n", + " lst.append(i['name'])\n", + " counter+=1\n", + " else:\n", + " break\n", + " return lst" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "36a8b3fb-b2cd-43d2-9429-59315a2f7758", + "metadata": {}, + "outputs": [], + "source": [ + "movies['cast'] = movies['cast'].apply(convert3)" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "id": "0b71015a-98bc-4f4a-941d-1ea0c87cab87", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitleoverviewgenreskeywordscastcrew
019995AvatarIn the 22nd century, a paraplegic Marine is di...[Action, Adventure, Fantasy, Science Fiction][culture clash, future, space war, space colon...[Sam Worthington, Zoe Saldana, Sigourney Weaver][{\"credit_id\": \"52fe48009251416c750aca23\", \"de...
1285Pirates of the Caribbean: At World's EndCaptain Barbossa, long believed to be dead, ha...[Adventure, Fantasy, Action][ocean, drug abuse, exotic island, east india ...[Johnny Depp, Orlando Bloom, Keira Knightley][{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de...
2206647SpectreA cryptic message from Bond’s past sends him o...[Action, Adventure, Crime][spy, based on novel, secret agent, sequel, mi...[Daniel Craig, Christoph Waltz, Léa Seydoux][{\"credit_id\": \"54805967c3a36829b5002c41\", \"de...
349026The Dark Knight RisesFollowing the death of District Attorney Harve...[Action, Crime, Drama, Thriller][dc comics, crime fighter, terrorist, secret i...[Christian Bale, Michael Caine, Gary Oldman][{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de...
449529John CarterJohn Carter is a war-weary, former military ca...[Action, Adventure, Science Fiction][based on novel, mars, medallion, space travel...[Taylor Kitsch, Lynn Collins, Samantha Morton][{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " overview \\\n", + "0 In the 22nd century, a paraplegic Marine is di... \n", + "1 Captain Barbossa, long believed to be dead, ha... \n", + "2 A cryptic message from Bond’s past sends him o... \n", + "3 Following the death of District Attorney Harve... \n", + "4 John Carter is a war-weary, former military ca... \n", + "\n", + " genres \\\n", + "0 [Action, Adventure, Fantasy, Science Fiction] \n", + "1 [Adventure, Fantasy, Action] \n", + "2 [Action, Adventure, Crime] \n", + "3 [Action, Crime, Drama, Thriller] \n", + "4 [Action, Adventure, Science Fiction] \n", + "\n", + " keywords \\\n", + "0 [culture clash, future, space war, space colon... \n", + "1 [ocean, drug abuse, exotic island, east india ... \n", + "2 [spy, based on novel, secret agent, sequel, mi... \n", + "3 [dc comics, crime fighter, terrorist, secret i... \n", + "4 [based on novel, mars, medallion, space travel... \n", + "\n", + " cast \\\n", + "0 [Sam Worthington, Zoe Saldana, Sigourney Weaver] \n", + "1 [Johnny Depp, Orlando Bloom, Keira Knightley] \n", + "2 [Daniel Craig, Christoph Waltz, Léa Seydoux] \n", + "3 [Christian Bale, Michael Caine, Gary Oldman] \n", + "4 [Taylor Kitsch, Lynn Collins, Samantha Morton] \n", + "\n", + " crew \n", + "0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n", + "1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n", + "2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n", + "3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n", + "4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... " + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "id": "8b960be4-6bd8-42d3-b945-81afbf0f7c66", + "metadata": {}, + "outputs": [], + "source": [ + "import ast\n", + "def fetch_director(obj):\n", + " lst = []\n", + " for i in ast.literal_eval(obj):\n", + " if i['job'] == 'Director':\n", + " lst.append(i['name'])\n", + " break\n", + " return lst" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "f68ff67e-5275-4957-b404-304ffd6a7d48", + "metadata": {}, + "outputs": [], + "source": [ + "movies['crew'] = movies['crew'].apply(fetch_director)" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "id": "59113019-bc9f-466e-af1c-bb6249ae0be7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitleoverviewgenreskeywordscastcrew
019995AvatarIn the 22nd century, a paraplegic Marine is di...[Action, Adventure, Fantasy, Science Fiction][culture clash, future, space war, space colon...[Sam Worthington, Zoe Saldana, Sigourney Weaver][James Cameron]
1285Pirates of the Caribbean: At World's EndCaptain Barbossa, long believed to be dead, ha...[Adventure, Fantasy, Action][ocean, drug abuse, exotic island, east india ...[Johnny Depp, Orlando Bloom, Keira Knightley][Gore Verbinski]
2206647SpectreA cryptic message from Bond’s past sends him o...[Action, Adventure, Crime][spy, based on novel, secret agent, sequel, mi...[Daniel Craig, Christoph Waltz, Léa Seydoux][Sam Mendes]
349026The Dark Knight RisesFollowing the death of District Attorney Harve...[Action, Crime, Drama, Thriller][dc comics, crime fighter, terrorist, secret i...[Christian Bale, Michael Caine, Gary Oldman][Christopher Nolan]
449529John CarterJohn Carter is a war-weary, former military ca...[Action, Adventure, Science Fiction][based on novel, mars, medallion, space travel...[Taylor Kitsch, Lynn Collins, Samantha Morton][Andrew Stanton]
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " overview \\\n", + "0 In the 22nd century, a paraplegic Marine is di... \n", + "1 Captain Barbossa, long believed to be dead, ha... \n", + "2 A cryptic message from Bond’s past sends him o... \n", + "3 Following the death of District Attorney Harve... \n", + "4 John Carter is a war-weary, former military ca... \n", + "\n", + " genres \\\n", + "0 [Action, Adventure, Fantasy, Science Fiction] \n", + "1 [Adventure, Fantasy, Action] \n", + "2 [Action, Adventure, Crime] \n", + "3 [Action, Crime, Drama, Thriller] \n", + "4 [Action, Adventure, Science Fiction] \n", + "\n", + " keywords \\\n", + "0 [culture clash, future, space war, space colon... \n", + "1 [ocean, drug abuse, exotic island, east india ... \n", + "2 [spy, based on novel, secret agent, sequel, mi... \n", + "3 [dc comics, crime fighter, terrorist, secret i... \n", + "4 [based on novel, mars, medallion, space travel... \n", + "\n", + " cast crew \n", + "0 [Sam Worthington, Zoe Saldana, Sigourney Weaver] [James Cameron] \n", + "1 [Johnny Depp, Orlando Bloom, Keira Knightley] [Gore Verbinski] \n", + "2 [Daniel Craig, Christoph Waltz, Léa Seydoux] [Sam Mendes] \n", + "3 [Christian Bale, Michael Caine, Gary Oldman] [Christopher Nolan] \n", + "4 [Taylor Kitsch, Lynn Collins, Samantha Morton] [Andrew Stanton] " + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 164, + "id": "898dc96a-4431-455b-9e1a-b67044db185c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['In',\n", + " 'the',\n", + " '22nd',\n", + " 'century,',\n", + " 'a',\n", + " 'paraplegic',\n", + " 'Marine',\n", + " 'is',\n", + " 'dispatched',\n", + " 'to',\n", + " 'the',\n", + " 'moon',\n", + " 'Pandora',\n", + " 'on',\n", + " 'a',\n", + " 'unique',\n", + " 'mission,',\n", + " 'but',\n", + " 'becomes',\n", + " 'torn',\n", + " 'between',\n", + " 'following',\n", + " 'orders',\n", + " 'and',\n", + " 'protecting',\n", + " 'an',\n", + " 'alien',\n", + " 'civilization.']" + ] + }, + "execution_count": 164, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies['overview'][0]" + ] + }, + { + "cell_type": "code", + "execution_count": 166, + "id": "5da13ce7-d448-41db-b40a-efa37c224809", + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'list' object has no attribute 'split'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[166], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m movies[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124moverview\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m movies[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124moverview\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m x:x\u001b[38;5;241m.\u001b[39msplit())\n", + "File \u001b[1;32m~\\anaconda\\Lib\\site-packages\\pandas\\core\\series.py:4924\u001b[0m, in \u001b[0;36mSeries.apply\u001b[1;34m(self, func, convert_dtype, args, by_row, **kwargs)\u001b[0m\n\u001b[0;32m 4789\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mapply\u001b[39m(\n\u001b[0;32m 4790\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 4791\u001b[0m func: AggFuncType,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 4796\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[0;32m 4797\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m DataFrame \u001b[38;5;241m|\u001b[39m Series:\n\u001b[0;32m 4798\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 4799\u001b[0m \u001b[38;5;124;03m Invoke function on values of Series.\u001b[39;00m\n\u001b[0;32m 4800\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 4915\u001b[0m \u001b[38;5;124;03m dtype: float64\u001b[39;00m\n\u001b[0;32m 4916\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m 4917\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m SeriesApply(\n\u001b[0;32m 4918\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 4919\u001b[0m func,\n\u001b[0;32m 4920\u001b[0m convert_dtype\u001b[38;5;241m=\u001b[39mconvert_dtype,\n\u001b[0;32m 4921\u001b[0m by_row\u001b[38;5;241m=\u001b[39mby_row,\n\u001b[0;32m 4922\u001b[0m args\u001b[38;5;241m=\u001b[39margs,\n\u001b[0;32m 4923\u001b[0m kwargs\u001b[38;5;241m=\u001b[39mkwargs,\n\u001b[1;32m-> 4924\u001b[0m )\u001b[38;5;241m.\u001b[39mapply()\n", + "File \u001b[1;32m~\\anaconda\\Lib\\site-packages\\pandas\\core\\apply.py:1427\u001b[0m, in \u001b[0;36mSeriesApply.apply\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1424\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mapply_compat()\n\u001b[0;32m 1426\u001b[0m \u001b[38;5;66;03m# self.func is Callable\u001b[39;00m\n\u001b[1;32m-> 1427\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mapply_standard()\n", + "File \u001b[1;32m~\\anaconda\\Lib\\site-packages\\pandas\\core\\apply.py:1507\u001b[0m, in \u001b[0;36mSeriesApply.apply_standard\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1501\u001b[0m \u001b[38;5;66;03m# row-wise access\u001b[39;00m\n\u001b[0;32m 1502\u001b[0m \u001b[38;5;66;03m# apply doesn't have a `na_action` keyword and for backward compat reasons\u001b[39;00m\n\u001b[0;32m 1503\u001b[0m \u001b[38;5;66;03m# we need to give `na_action=\"ignore\"` for categorical data.\u001b[39;00m\n\u001b[0;32m 1504\u001b[0m \u001b[38;5;66;03m# TODO: remove the `na_action=\"ignore\"` when that default has been changed in\u001b[39;00m\n\u001b[0;32m 1505\u001b[0m \u001b[38;5;66;03m# Categorical (GH51645).\u001b[39;00m\n\u001b[0;32m 1506\u001b[0m action \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mignore\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(obj\u001b[38;5;241m.\u001b[39mdtype, CategoricalDtype) \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m-> 1507\u001b[0m mapped \u001b[38;5;241m=\u001b[39m obj\u001b[38;5;241m.\u001b[39m_map_values(\n\u001b[0;32m 1508\u001b[0m mapper\u001b[38;5;241m=\u001b[39mcurried, na_action\u001b[38;5;241m=\u001b[39maction, convert\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconvert_dtype\n\u001b[0;32m 1509\u001b[0m )\n\u001b[0;32m 1511\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(mapped) \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(mapped[\u001b[38;5;241m0\u001b[39m], ABCSeries):\n\u001b[0;32m 1512\u001b[0m \u001b[38;5;66;03m# GH#43986 Need to do list(mapped) in order to get treated as nested\u001b[39;00m\n\u001b[0;32m 1513\u001b[0m \u001b[38;5;66;03m# See also GH#25959 regarding EA support\u001b[39;00m\n\u001b[0;32m 1514\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m obj\u001b[38;5;241m.\u001b[39m_constructor_expanddim(\u001b[38;5;28mlist\u001b[39m(mapped), index\u001b[38;5;241m=\u001b[39mobj\u001b[38;5;241m.\u001b[39mindex)\n", + "File \u001b[1;32m~\\anaconda\\Lib\\site-packages\\pandas\\core\\base.py:921\u001b[0m, in \u001b[0;36mIndexOpsMixin._map_values\u001b[1;34m(self, mapper, na_action, convert)\u001b[0m\n\u001b[0;32m 918\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(arr, ExtensionArray):\n\u001b[0;32m 919\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m arr\u001b[38;5;241m.\u001b[39mmap(mapper, na_action\u001b[38;5;241m=\u001b[39mna_action)\n\u001b[1;32m--> 921\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m algorithms\u001b[38;5;241m.\u001b[39mmap_array(arr, mapper, na_action\u001b[38;5;241m=\u001b[39mna_action, convert\u001b[38;5;241m=\u001b[39mconvert)\n", + "File \u001b[1;32m~\\anaconda\\Lib\\site-packages\\pandas\\core\\algorithms.py:1743\u001b[0m, in \u001b[0;36mmap_array\u001b[1;34m(arr, mapper, na_action, convert)\u001b[0m\n\u001b[0;32m 1741\u001b[0m values \u001b[38;5;241m=\u001b[39m arr\u001b[38;5;241m.\u001b[39mastype(\u001b[38;5;28mobject\u001b[39m, copy\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m 1742\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m na_action \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m-> 1743\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mmap_infer(values, mapper, convert\u001b[38;5;241m=\u001b[39mconvert)\n\u001b[0;32m 1744\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 1745\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mmap_infer_mask(\n\u001b[0;32m 1746\u001b[0m values, mapper, mask\u001b[38;5;241m=\u001b[39misna(values)\u001b[38;5;241m.\u001b[39mview(np\u001b[38;5;241m.\u001b[39muint8), convert\u001b[38;5;241m=\u001b[39mconvert\n\u001b[0;32m 1747\u001b[0m )\n", + "File \u001b[1;32mlib.pyx:2972\u001b[0m, in \u001b[0;36mpandas._libs.lib.map_infer\u001b[1;34m()\u001b[0m\n", + "Cell \u001b[1;32mIn[166], line 1\u001b[0m, in \u001b[0;36m\u001b[1;34m(x)\u001b[0m\n\u001b[1;32m----> 1\u001b[0m movies[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124moverview\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m movies[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124moverview\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m x:x\u001b[38;5;241m.\u001b[39msplit())\n", + "\u001b[1;31mAttributeError\u001b[0m: 'list' object has no attribute 'split'" + ] + } + ], + "source": [ + "movies['overview'] = movies['overview'].apply(lambda x:x.split())" + ] + }, + { + "cell_type": "code", + "execution_count": 168, + "id": "597e6177-a424-403c-808d-4af02dccef29", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitleoverviewgenreskeywordscastcrewtags
019995Avatar[In, the, 22nd, century,, a, paraplegic, Marin...[Action, Adventure, Fantasy, ScienceFiction][cultureclash, future, spacewar, spacecolony, ...[SamWorthington, ZoeSaldana, SigourneyWeaver][JamesCameron][Action, Adventure, Fantasy, ScienceFiction, c...
1285Pirates of the Caribbean: At World's End[Captain, Barbossa,, long, believed, to, be, d...[Adventure, Fantasy, Action][ocean, drugabuse, exoticisland, eastindiatrad...[JohnnyDepp, OrlandoBloom, KeiraKnightley][GoreVerbinski][Adventure, Fantasy, Action, ocean, drugabuse,...
2206647Spectre[A, cryptic, message, from, Bond’s, past, send...[Action, Adventure, Crime][spy, basedonnovel, secretagent, sequel, mi6, ...[DanielCraig, ChristophWaltz, LéaSeydoux][SamMendes][Action, Adventure, Crime, spy, basedonnovel, ...
349026The Dark Knight Rises[Following, the, death, of, District, Attorney...[Action, Crime, Drama, Thriller][dccomics, crimefighter, terrorist, secretiden...[ChristianBale, MichaelCaine, GaryOldman][ChristopherNolan][Action, Crime, Drama, Thriller, dccomics, cri...
449529John Carter[John, Carter, is, a, war-weary,, former, mili...[Action, Adventure, ScienceFiction][basedonnovel, mars, medallion, spacetravel, p...[TaylorKitsch, LynnCollins, SamanthaMorton][AndrewStanton][Action, Adventure, ScienceFiction, basedonnov...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " overview \\\n", + "0 [In, the, 22nd, century,, a, paraplegic, Marin... \n", + "1 [Captain, Barbossa,, long, believed, to, be, d... \n", + "2 [A, cryptic, message, from, Bond’s, past, send... \n", + "3 [Following, the, death, of, District, Attorney... \n", + "4 [John, Carter, is, a, war-weary,, former, mili... \n", + "\n", + " genres \\\n", + "0 [Action, Adventure, Fantasy, ScienceFiction] \n", + "1 [Adventure, Fantasy, Action] \n", + "2 [Action, Adventure, Crime] \n", + "3 [Action, Crime, Drama, Thriller] \n", + "4 [Action, Adventure, ScienceFiction] \n", + "\n", + " keywords \\\n", + "0 [cultureclash, future, spacewar, spacecolony, ... \n", + "1 [ocean, drugabuse, exoticisland, eastindiatrad... \n", + "2 [spy, basedonnovel, secretagent, sequel, mi6, ... \n", + "3 [dccomics, crimefighter, terrorist, secretiden... \n", + "4 [basedonnovel, mars, medallion, spacetravel, p... \n", + "\n", + " cast crew \\\n", + "0 [SamWorthington, ZoeSaldana, SigourneyWeaver] [JamesCameron] \n", + "1 [JohnnyDepp, OrlandoBloom, KeiraKnightley] [GoreVerbinski] \n", + "2 [DanielCraig, ChristophWaltz, LéaSeydoux] [SamMendes] \n", + "3 [ChristianBale, MichaelCaine, GaryOldman] [ChristopherNolan] \n", + "4 [TaylorKitsch, LynnCollins, SamanthaMorton] [AndrewStanton] \n", + "\n", + " tags \n", + "0 [Action, Adventure, Fantasy, ScienceFiction, c... \n", + "1 [Adventure, Fantasy, Action, ocean, drugabuse,... \n", + "2 [Action, Adventure, Crime, spy, basedonnovel, ... \n", + "3 [Action, Crime, Drama, Thriller, dccomics, cri... \n", + "4 [Action, Adventure, ScienceFiction, basedonnov... " + ] + }, + "execution_count": 168, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 170, + "id": "16a02880-efd6-4282-bd8a-f553d69c5214", + "metadata": {}, + "outputs": [], + "source": [ + "movies['genres'] = movies['genres'].apply(lambda x: [i.replace(\" \",\"\") for i in x])\n", + "movies['keywords'] = movies['keywords'].apply(lambda x: [i.replace(\" \",\"\") for i in x])\n", + "movies['cast'] = movies['cast'].apply(lambda x: [i.replace(\" \",\"\") for i in x])\n", + "movies['crew'] = movies['crew'].apply(lambda x: [i.replace(\" \",\"\") for i in x])" + ] + }, + { + "cell_type": "code", + "execution_count": 172, + "id": "490ba3fa-a1d6-4c76-8364-03ed0ad353e6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitleoverviewgenreskeywordscastcrewtags
019995Avatar[In, the, 22nd, century,, a, paraplegic, Marin...[Action, Adventure, Fantasy, ScienceFiction][cultureclash, future, spacewar, spacecolony, ...[SamWorthington, ZoeSaldana, SigourneyWeaver][JamesCameron][Action, Adventure, Fantasy, ScienceFiction, c...
1285Pirates of the Caribbean: At World's End[Captain, Barbossa,, long, believed, to, be, d...[Adventure, Fantasy, Action][ocean, drugabuse, exoticisland, eastindiatrad...[JohnnyDepp, OrlandoBloom, KeiraKnightley][GoreVerbinski][Adventure, Fantasy, Action, ocean, drugabuse,...
2206647Spectre[A, cryptic, message, from, Bond’s, past, send...[Action, Adventure, Crime][spy, basedonnovel, secretagent, sequel, mi6, ...[DanielCraig, ChristophWaltz, LéaSeydoux][SamMendes][Action, Adventure, Crime, spy, basedonnovel, ...
349026The Dark Knight Rises[Following, the, death, of, District, Attorney...[Action, Crime, Drama, Thriller][dccomics, crimefighter, terrorist, secretiden...[ChristianBale, MichaelCaine, GaryOldman][ChristopherNolan][Action, Crime, Drama, Thriller, dccomics, cri...
449529John Carter[John, Carter, is, a, war-weary,, former, mili...[Action, Adventure, ScienceFiction][basedonnovel, mars, medallion, spacetravel, p...[TaylorKitsch, LynnCollins, SamanthaMorton][AndrewStanton][Action, Adventure, ScienceFiction, basedonnov...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " overview \\\n", + "0 [In, the, 22nd, century,, a, paraplegic, Marin... \n", + "1 [Captain, Barbossa,, long, believed, to, be, d... \n", + "2 [A, cryptic, message, from, Bond’s, past, send... \n", + "3 [Following, the, death, of, District, Attorney... \n", + "4 [John, Carter, is, a, war-weary,, former, mili... \n", + "\n", + " genres \\\n", + "0 [Action, Adventure, Fantasy, ScienceFiction] \n", + "1 [Adventure, Fantasy, Action] \n", + "2 [Action, Adventure, Crime] \n", + "3 [Action, Crime, Drama, Thriller] \n", + "4 [Action, Adventure, ScienceFiction] \n", + "\n", + " keywords \\\n", + "0 [cultureclash, future, spacewar, spacecolony, ... \n", + "1 [ocean, drugabuse, exoticisland, eastindiatrad... \n", + "2 [spy, basedonnovel, secretagent, sequel, mi6, ... \n", + "3 [dccomics, crimefighter, terrorist, secretiden... \n", + "4 [basedonnovel, mars, medallion, spacetravel, p... \n", + "\n", + " cast crew \\\n", + "0 [SamWorthington, ZoeSaldana, SigourneyWeaver] [JamesCameron] \n", + "1 [JohnnyDepp, OrlandoBloom, KeiraKnightley] [GoreVerbinski] \n", + "2 [DanielCraig, ChristophWaltz, LéaSeydoux] [SamMendes] \n", + "3 [ChristianBale, MichaelCaine, GaryOldman] [ChristopherNolan] \n", + "4 [TaylorKitsch, LynnCollins, SamanthaMorton] [AndrewStanton] \n", + "\n", + " tags \n", + "0 [Action, Adventure, Fantasy, ScienceFiction, c... \n", + "1 [Adventure, Fantasy, Action, ocean, drugabuse,... \n", + "2 [Action, Adventure, Crime, spy, basedonnovel, ... \n", + "3 [Action, Crime, Drama, Thriller, dccomics, cri... \n", + "4 [Action, Adventure, ScienceFiction, basedonnov... " + ] + }, + "execution_count": 172, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 174, + "id": "94933c5d-d483-4607-9953-f205375f3b77", + "metadata": {}, + "outputs": [], + "source": [ + "movies['tags'] = movies['overview'] + movies['genres'] + movies['keywords'] + movies['cast'] + movies['crew']" + ] + }, + { + "cell_type": "code", + "execution_count": 176, + "id": "92f543b3-7275-4d32-b86b-95fe10362534", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([list(['In', 'the', '22nd', 'century,', 'a', 'paraplegic', 'Marine', 'is', 'dispatched', 'to', 'the', 'moon', 'Pandora', 'on', 'a', 'unique', 'mission,', 'but', 'becomes', 'torn', 'between', 'following', 'orders', 'and', 'protecting', 'an', 'alien', 'civilization.', 'Action', 'Adventure', 'Fantasy', 'ScienceFiction', 'cultureclash', 'future', 'spacewar', 'spacecolony', 'society', 'spacetravel', 'futuristic', 'romance', 'space', 'alien', 'tribe', 'alienplanet', 'cgi', 'marine', 'soldier', 'battle', 'loveaffair', 'antiwar', 'powerrelations', 'mindandsoul', '3d', 'SamWorthington', 'ZoeSaldana', 'SigourneyWeaver', 'JamesCameron']),\n", + " list(['Captain', 'Barbossa,', 'long', 'believed', 'to', 'be', 'dead,', 'has', 'come', 'back', 'to', 'life', 'and', 'is', 'headed', 'to', 'the', 'edge', 'of', 'the', 'Earth', 'with', 'Will', 'Turner', 'and', 'Elizabeth', 'Swann.', 'But', 'nothing', 'is', 'quite', 'as', 'it', 'seems.', 'Adventure', 'Fantasy', 'Action', 'ocean', 'drugabuse', 'exoticisland', 'eastindiatradingcompany', \"loveofone'slife\", 'traitor', 'shipwreck', 'strongwoman', 'ship', 'alliance', 'calypso', 'afterlife', 'fighter', 'pirate', 'swashbuckler', 'aftercreditsstinger', 'JohnnyDepp', 'OrlandoBloom', 'KeiraKnightley', 'GoreVerbinski']),\n", + " list(['A', 'cryptic', 'message', 'from', 'Bond’s', 'past', 'sends', 'him', 'on', 'a', 'trail', 'to', 'uncover', 'a', 'sinister', 'organization.', 'While', 'M', 'battles', 'political', 'forces', 'to', 'keep', 'the', 'secret', 'service', 'alive,', 'Bond', 'peels', 'back', 'the', 'layers', 'of', 'deceit', 'to', 'reveal', 'the', 'terrible', 'truth', 'behind', 'SPECTRE.', 'Action', 'Adventure', 'Crime', 'spy', 'basedonnovel', 'secretagent', 'sequel', 'mi6', 'britishsecretservice', 'unitedkingdom', 'DanielCraig', 'ChristophWaltz', 'LéaSeydoux', 'SamMendes']),\n", + " list(['Following', 'the', 'death', 'of', 'District', 'Attorney', 'Harvey', 'Dent,', 'Batman', 'assumes', 'responsibility', 'for', \"Dent's\", 'crimes', 'to', 'protect', 'the', 'late', \"attorney's\", 'reputation', 'and', 'is', 'subsequently', 'hunted', 'by', 'the', 'Gotham', 'City', 'Police', 'Department.', 'Eight', 'years', 'later,', 'Batman', 'encounters', 'the', 'mysterious', 'Selina', 'Kyle', 'and', 'the', 'villainous', 'Bane,', 'a', 'new', 'terrorist', 'leader', 'who', 'overwhelms', \"Gotham's\", 'finest.', 'The', 'Dark', 'Knight', 'resurfaces', 'to', 'protect', 'a', 'city', 'that', 'has', 'branded', 'him', 'an', 'enemy.', 'Action', 'Crime', 'Drama', 'Thriller', 'dccomics', 'crimefighter', 'terrorist', 'secretidentity', 'burglar', 'hostagedrama', 'timebomb', 'gothamcity', 'vigilante', 'cover-up', 'superhero', 'villainess', 'tragichero', 'terrorism', 'destruction', 'catwoman', 'catburglar', 'imax', 'flood', 'criminalunderworld', 'batman', 'ChristianBale', 'MichaelCaine', 'GaryOldman', 'ChristopherNolan']),\n", + " list(['John', 'Carter', 'is', 'a', 'war-weary,', 'former', 'military', 'captain', \"who's\", 'inexplicably', 'transported', 'to', 'the', 'mysterious', 'and', 'exotic', 'planet', 'of', 'Barsoom', '(Mars)', 'and', 'reluctantly', 'becomes', 'embroiled', 'in', 'an', 'epic', 'conflict.', \"It's\", 'a', 'world', 'on', 'the', 'brink', 'of', 'collapse,', 'and', 'Carter', 'rediscovers', 'his', 'humanity', 'when', 'he', 'realizes', 'the', 'survival', 'of', 'Barsoom', 'and', 'its', 'people', 'rests', 'in', 'his', 'hands.', 'Action', 'Adventure', 'ScienceFiction', 'basedonnovel', 'mars', 'medallion', 'spacetravel', 'princess', 'alien', 'steampunk', 'martian', 'escape', 'edgarriceburroughs', 'alienrace', 'superhumanstrength', 'marscivilization', 'swordandplanet', '19thcentury', '3d', 'TaylorKitsch', 'LynnCollins', 'SamanthaMorton', 'AndrewStanton'])],\n", + " dtype=object)" + ] + }, + "execution_count": 176, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "movies.head(5)['tags'].values" + ] + }, + { + "cell_type": "code", + "execution_count": 178, + "id": "1ace7fae-1a69-4735-866b-1180e17f1366", + "metadata": {}, + "outputs": [], + "source": [ + "df = movies[['movie_id','title','tags']]" + ] + }, + { + "cell_type": "code", + "execution_count": 180, + "id": "407ce4d5-a67d-46b0-b3ed-539efa3d126a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitletags
019995Avatar[In, the, 22nd, century,, a, paraplegic, Marin...
1285Pirates of the Caribbean: At World's End[Captain, Barbossa,, long, believed, to, be, d...
2206647Spectre[A, cryptic, message, from, Bond’s, past, send...
349026The Dark Knight Rises[Following, the, death, of, District, Attorney...
449529John Carter[John, Carter, is, a, war-weary,, former, mili...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " tags \n", + "0 [In, the, 22nd, century,, a, paraplegic, Marin... \n", + "1 [Captain, Barbossa,, long, believed, to, be, d... \n", + "2 [A, cryptic, message, from, Bond’s, past, send... \n", + "3 [Following, the, death, of, District, Attorney... \n", + "4 [John, Carter, is, a, war-weary,, former, mili... " + ] + }, + "execution_count": 180, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 182, + "id": "23298ac3-92d7-456c-9bd7-2cf5356e271a", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\vaish\\AppData\\Local\\Temp\\ipykernel_10236\\4267108141.py:1: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " df['tags'] = df['tags'].apply(lambda x:\" \".join(x))\n" + ] + } + ], + "source": [ + "df['tags'] = df['tags'].apply(lambda x:\" \".join(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 184, + "id": "22c2efd8-15c7-4333-b9b6-46d12705a727", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
movie_idtitletags
019995AvatarIn the 22nd century, a paraplegic Marine is di...
1285Pirates of the Caribbean: At World's EndCaptain Barbossa, long believed to be dead, ha...
2206647SpectreA cryptic message from Bond’s past sends him o...
349026The Dark Knight RisesFollowing the death of District Attorney Harve...
449529John CarterJohn Carter is a war-weary, former military ca...
\n", + "
" + ], + "text/plain": [ + " movie_id title \\\n", + "0 19995 Avatar \n", + "1 285 Pirates of the Caribbean: At World's End \n", + "2 206647 Spectre \n", + "3 49026 The Dark Knight Rises \n", + "4 49529 John Carter \n", + "\n", + " tags \n", + "0 In the 22nd century, a paraplegic Marine is di... \n", + "1 Captain Barbossa, long believed to be dead, ha... \n", + "2 A cryptic message from Bond’s past sends him o... \n", + "3 Following the death of District Attorney Harve... \n", + "4 John Carter is a war-weary, former military ca... " + ] + }, + "execution_count": 184, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 186, + "id": "66328318-810c-422c-9e2f-1dac1971f885", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'In the 22nd century, a paraplegic Marine is dispatched to the moon Pandora on a unique mission, but becomes torn between following orders and protecting an alien civilization. Action Adventure Fantasy ScienceFiction cultureclash future spacewar spacecolony society spacetravel futuristic romance space alien tribe alienplanet cgi marine soldier battle loveaffair antiwar powerrelations mindandsoul 3d SamWorthington ZoeSaldana SigourneyWeaver JamesCameron'" + ] + }, + "execution_count": 186, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['tags'][0]" + ] + }, + { + "cell_type": "code", + "execution_count": 188, + "id": "b4d4a0ca-57b3-4c83-9400-3bc89997613f", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\vaish\\AppData\\Local\\Temp\\ipykernel_10236\\841579467.py:1: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " df['tags'] = df['tags'].apply(lambda x:x.lower())\n" + ] + } + ], + "source": [ + "df['tags'] = df['tags'].apply(lambda x:x.lower())" + ] + }, + { + "cell_type": "code", + "execution_count": 218, + "id": "87727b0e-7a8c-472b-9ddb-3bc9194fd4c5", + "metadata": {}, + "outputs": [], + "source": [ + "from nltk.stem.porter import PorterStemmer\n", + "ps = PorterStemmer()" + ] + }, + { + "cell_type": "code", + "execution_count": 228, + "id": "e4e40949-216e-40cc-8a56-a3e51e2a7ebd", + "metadata": {}, + "outputs": [], + "source": [ + "def stem(text):\n", + " y = []\n", + " for i in text.split():\n", + " y.append(ps.stem(i))\n", + " return \" \".join(y)" + ] + }, + { + "cell_type": "code", + "execution_count": 232, + "id": "b8ff79cd-e4a3-4674-96fe-fe9886a5efb3", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\vaish\\AppData\\Local\\Temp\\ipykernel_10236\\866399325.py:1: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " df['tags'] = df['tags'].apply(stem)\n" + ] + } + ], + "source": [ + "df['tags'] = df['tags'].apply(stem)" + ] + }, + { + "cell_type": "code", + "execution_count": 234, + "id": "79333e39-a829-4816-b2a5-53d80dde0ba7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'in the 22nd century, a parapleg marin is dispatch to the moon pandora on a uniqu mission, but becom torn between follow order and protect an alien civilization. action adventur fantasi sciencefict cultureclash futur spacewar spacecoloni societi spacetravel futurist romanc space alien tribe alienplanet cgi marin soldier battl loveaffair antiwar powerrel mindandsoul 3d samworthington zoesaldana sigourneyweav jamescameron'" + ] + }, + "execution_count": 234, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['tags'][0]" + ] + }, + { + "cell_type": "code", + "execution_count": 236, + "id": "598fa1f5-b209-446a-83ac-1c7949517dc8", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.feature_extraction.text import CountVectorizer\n", + "cv = CountVectorizer(max_features=5000, stop_words = 'english')" + ] + }, + { + "cell_type": "code", + "execution_count": 238, + "id": "978474ea-c9c0-4d3d-96e7-a660f4908478", + "metadata": {}, + "outputs": [], + "source": [ + "vectors = cv.fit_transform(df['tags']).toarray()" + ] + }, + { + "cell_type": "code", + "execution_count": 240, + "id": "8cfdbcdf-de37-4091-9e2a-e55841078d03", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0, 0, 0, ..., 0, 0, 0], dtype=int64)" + ] + }, + "execution_count": 240, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vectors[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 242, + "id": "83979d3f-8ba5-47cf-af0e-b5944233c8ea", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['000', '007', '10', ..., 'zone', 'zoo', 'zooeydeschanel'],\n", + " dtype=object)" + ] + }, + "execution_count": 242, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cv.get_feature_names_out()" + ] + }, + { + "cell_type": "code", + "execution_count": 214, + "id": "af2ecdda-cff7-48a7-b3d6-86f8ae3eb88c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: nltk in c:\\users\\vaish\\anaconda\\lib\\site-packages (3.9.1)\n", + "Requirement already satisfied: click in c:\\users\\vaish\\anaconda\\lib\\site-packages (from nltk) (8.1.7)\n", + "Requirement already satisfied: joblib in c:\\users\\vaish\\anaconda\\lib\\site-packages (from nltk) (1.4.2)\n", + "Requirement already satisfied: regex>=2021.8.3 in c:\\users\\vaish\\anaconda\\lib\\site-packages (from nltk) (2023.10.3)\n", + "Requirement already satisfied: tqdm in c:\\users\\vaish\\anaconda\\lib\\site-packages (from nltk) (4.66.4)\n", + "Requirement already satisfied: colorama in c:\\users\\vaish\\anaconda\\lib\\site-packages (from click->nltk) (0.4.6)\n" + ] + } + ], + "source": [ + "!pip install nltk" + ] + }, + { + "cell_type": "code", + "execution_count": 244, + "id": "73024de2-14f4-4121-a519-944ab6af630a", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.metrics.pairwise import cosine_similarity" + ] + }, + { + "cell_type": "code", + "execution_count": 246, + "id": "66443bd2-9ac9-4acd-8931-42eacb23b62e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[1. , 0.08346223, 0.0860309 , ..., 0.04499213, 0. ,\n", + " 0. ],\n", + " [0.08346223, 1. , 0.06063391, ..., 0.02378257, 0. ,\n", + " 0.02615329],\n", + " [0.0860309 , 0.06063391, 1. , ..., 0.02451452, 0. ,\n", + " 0. ],\n", + " ...,\n", + " [0.04499213, 0.02378257, 0.02451452, ..., 1. , 0.03962144,\n", + " 0.04229549],\n", + " [0. , 0. , 0. , ..., 0.03962144, 1. ,\n", + " 0.08714204],\n", + " [0. , 0.02615329, 0. , ..., 0.04229549, 0.08714204,\n", + " 1. ]])" + ] + }, + "execution_count": 246, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cosine_similarity(vectors)" + ] + }, + { + "cell_type": "code", + "execution_count": 280, + "id": "03a649de-3dc4-4748-b07c-5a04cf5ae019", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1. , 0.08346223, 0.0860309 , ..., 0.04499213, 0. ,\n", + " 0. ])" + ] + }, + "execution_count": 280, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "similarity = cosine_similarity(vectors)\n", + "similarity[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 286, + "id": "cfdb6471-ba1c-4be6-b2c1-b586318b8f5a", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[(1214, 0.28676966733820225),\n", + " (2405, 0.26901379342448517),\n", + " (3728, 0.2605130246476754),\n", + " (507, 0.255608593705383),\n", + " (539, 0.25038669783359574)]" + ] + }, + "execution_count": 286, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sorted(list(enumerate(similarity[0])), reverse = True, key = lambda x:x[1])[1:6]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "de306422-63de-4f95-ac7c-7ffb4af34788", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 256, + "id": "8c858841-bad6-4a65-a014-48f4e601f7c8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1. , 0.08346223, 0.0860309 , ..., 0.04499213, 0. ,\n", + " 0. ])" + ] + }, + "execution_count": 256, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "similarity[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 298, + "id": "bb75ca03-c845-4549-b380-41b710299abe", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "119" + ] + }, + "execution_count": 298, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[ df['title']=='Batman Begins' ].index[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 300, + "id": "a5a91f7e-f9a8-4a16-b826-e92255c83d87", + "metadata": {}, + "outputs": [], + "source": [ + "def recommend(movie):\n", + " movie_index = df[df['title']==movie].index[0]\n", + " distances = similarity[movie_index]\n", + " movie_list = sorted(list(enumerate(distances)), reverse = True, key = lambda x:x[1])[1:6]\n", + " for i in movie_list:\n", + " print(df.iloc[i[0]].title)" + ] + }, + { + "cell_type": "code", + "execution_count": 316, + "id": "015c991d-0b7e-4a1a-b416-51ded8d037ba", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Notebook\n", + "Under the Same Moon\n", + "Ghost Ship\n", + "The Bounty\n", + "Pirates of the Caribbean: On Stranger Tides\n" + ] + } + ], + "source": [ + "recommend('Titanic')" + ] + }, + { + "cell_type": "code", + "execution_count": 328, + "id": "0fe77ac9-a828-4eef-8392-605df0aaa937", + "metadata": {}, + "outputs": [], + "source": [ + "import pickle\n", + "pickle.dump(df,open('movies.pkl','wb'))" + ] + }, + { + "cell_type": "code", + "execution_count": 330, + "id": "d94a6a2f-e67d-4e2b-9ddd-e9abbcd78745", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['Avatar', \"Pirates of the Caribbean: At World's End\", 'Spectre',\n", + " ..., 'Signed, Sealed, Delivered', 'Shanghai Calling',\n", + " 'My Date with Drew'], dtype=object)" + ] + }, + "execution_count": 330, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['title'].values" + ] + }, + { + "cell_type": "code", + "execution_count": 332, + "id": "55449a21-251e-4be4-b872-28f97e69f602", + "metadata": {}, + "outputs": [], + "source": [ + "pickle.dump(similarity, open('similarity.pkl','wb'))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}