{ "cells": [ { "cell_type": "markdown", "id": "c5802a21", "metadata": {}, "source": [ "# Project: Movies Recommendation System \n", "\n", " One significant category of machine learning algorithms that provides consumers with \"appropriate\" choices is the recommender system. All three sites—YouTube, Amazon, and Netflix—have systems that suggest videos or products to you based on your past behavior (called content-based filtering) or on the behaviors and preferences of other users who have your interests (Collaborative Filtering).\n", "\n", "Recommendation Systems work based on the similarity between either the content or the users who access the content.There are several ways to measure the similarity between two items. The recommendation systems use this similarity matrix to recommend the next most similar product to the user.\n", "\n", "In this project, we will build a machine learning model that would recommend movies based on a movie the user likes. This Machine Learning model would be based on Cosine Similarity.\n" ] }, { "cell_type": "markdown", "id": "45208056", "metadata": {}, "source": [ "## Importing dependencies" ] }, { "cell_type": "code", "execution_count": 1, "id": "fb34fc04", "metadata": {}, "outputs": [], "source": [ "import os\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns" ] }, { "cell_type": "markdown", "id": "60a47b8f", "metadata": {}, "source": [ "## Loading the Data" ] }, { "cell_type": "code", "execution_count": 2, "id": "22801041", "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": 3, "id": "365e7f1f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | budget | \n", "genres | \n", "homepage | \n", "id | \n", "keywords | \n", "original_language | \n", "original_title | \n", "overview | \n", "popularity | \n", "production_companies | \n", "production_countries | \n", "release_date | \n", "revenue | \n", "runtime | \n", "spoken_languages | \n", "status | \n", "tagline | \n", "title | \n", "vote_average | \n", "vote_count | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "237000000 | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n", "http://www.avatarmovie.com/ | \n", "19995 | \n", "[{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... | \n", "en | \n", "Avatar | \n", "In the 22nd century, a paraplegic Marine is di... | \n", "150.437577 | \n", "[{\"name\": \"Ingenious Film Partners\", \"id\": 289... | \n", "[{\"iso_3166_1\": \"US\", \"name\": \"United States o... | \n", "2009-12-10 | \n", "2787965087 | \n", "162.0 | \n", "[{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... | \n", "Released | \n", "Enter the World of Pandora. | \n", "Avatar | \n", "7.2 | \n", "11800 | \n", "
1 | \n", "300000000 | \n", "[{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... | \n", "http://disney.go.com/disneypictures/pirates/ | \n", "285 | \n", "[{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... | \n", "en | \n", "Pirates of the Caribbean: At World's End | \n", "Captain Barbossa, long believed to be dead, ha... | \n", "139.082615 | \n", "[{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"... | \n", "[{\"iso_3166_1\": \"US\", \"name\": \"United States o... | \n", "2007-05-19 | \n", "961000000 | \n", "169.0 | \n", "[{\"iso_639_1\": \"en\", \"name\": \"English\"}] | \n", "Released | \n", "At the end of the world, the adventure begins. | \n", "Pirates of the Caribbean: At World's End | \n", "6.9 | \n", "4500 | \n", "
2 | \n", "245000000 | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n", "http://www.sonypictures.com/movies/spectre/ | \n", "206647 | \n", "[{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... | \n", "en | \n", "Spectre | \n", "A cryptic message from Bond’s past sends him o... | \n", "107.376788 | \n", "[{\"name\": \"Columbia Pictures\", \"id\": 5}, {\"nam... | \n", "[{\"iso_3166_1\": \"GB\", \"name\": \"United Kingdom\"... | \n", "2015-10-26 | \n", "880674609 | \n", "148.0 | \n", "[{\"iso_639_1\": \"fr\", \"name\": \"Fran\\u00e7ais\"},... | \n", "Released | \n", "A Plan No One Escapes | \n", "Spectre | \n", "6.3 | \n", "4466 | \n", "
3 | \n", "250000000 | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam... | \n", "http://www.thedarkknightrises.com/ | \n", "49026 | \n", "[{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... | \n", "en | \n", "The Dark Knight Rises | \n", "Following the death of District Attorney Harve... | \n", "112.312950 | \n", "[{\"name\": \"Legendary Pictures\", \"id\": 923}, {\"... | \n", "[{\"iso_3166_1\": \"US\", \"name\": \"United States o... | \n", "2012-07-16 | \n", "1084939099 | \n", "165.0 | \n", "[{\"iso_639_1\": \"en\", \"name\": \"English\"}] | \n", "Released | \n", "The Legend Ends | \n", "The Dark Knight Rises | \n", "7.6 | \n", "9106 | \n", "
4 | \n", "260000000 | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n", "http://movies.disney.com/john-carter | \n", "49529 | \n", "[{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... | \n", "en | \n", "John Carter | \n", "John Carter is a war-weary, former military ca... | \n", "43.926995 | \n", "[{\"name\": \"Walt Disney Pictures\", \"id\": 2}] | \n", "[{\"iso_3166_1\": \"US\", \"name\": \"United States o... | \n", "2012-03-07 | \n", "284139100 | \n", "132.0 | \n", "[{\"iso_639_1\": \"en\", \"name\": \"English\"}] | \n", "Released | \n", "Lost in our world, found in another. | \n", "John Carter | \n", "6.1 | \n", "2124 | \n", "
\n", " | movie_id | \n", "title | \n", "cast | \n", "crew | \n", "
---|---|---|---|---|
0 | \n", "19995 | \n", "Avatar | \n", "[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... | \n", "[{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n", "
1 | \n", "285 | \n", "Pirates of the Caribbean: At World's End | \n", "[{\"cast_id\": 4, \"character\": \"Captain Jack Spa... | \n", "[{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n", "
2 | \n", "206647 | \n", "Spectre | \n", "[{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... | \n", "[{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n", "
3 | \n", "49026 | \n", "The Dark Knight Rises | \n", "[{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... | \n", "[{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n", "
4 | \n", "49529 | \n", "John Carter | \n", "[{\"cast_id\": 5, \"character\": \"John Carter\", \"c... | \n", "[{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n", "
\n", " | movie_id | \n", "title | \n", "overview | \n", "genres | \n", "cast | \n", "keywords | \n", "crew | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "19995 | \n", "Avatar | \n", "In the 22nd century, a paraplegic Marine is di... | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n", "[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... | \n", "[{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... | \n", "[{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n", "
1 | \n", "285 | \n", "Pirates of the Caribbean: At World's End | \n", "Captain Barbossa, long believed to be dead, ha... | \n", "[{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... | \n", "[{\"cast_id\": 4, \"character\": \"Captain Jack Spa... | \n", "[{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... | \n", "[{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n", "
2 | \n", "206647 | \n", "Spectre | \n", "A cryptic message from Bond’s past sends him o... | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n", "[{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... | \n", "[{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... | \n", "[{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n", "
3 | \n", "49026 | \n", "The Dark Knight Rises | \n", "Following the death of District Attorney Harve... | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam... | \n", "[{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... | \n", "[{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... | \n", "[{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n", "
4 | \n", "49529 | \n", "John Carter | \n", "John Carter is a war-weary, former military ca... | \n", "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n", "[{\"cast_id\": 5, \"character\": \"John Carter\", \"c... | \n", "[{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... | \n", "[{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n", "
\n", " | movie_id | \n", "title | \n", "overview | \n", "genres | \n", "cast | \n", "keywords | \n", "crew | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "19995 | \n", "Avatar | \n", "[In, the, 22nd, century,, a, paraplegic, Marin... | \n", "[Action, Adventure, Fantasy, Science Fiction] | \n", "[Sam Worthington, Zoe Saldana, Sigourney Weaver] | \n", "[culture clash, future, space war, space colon... | \n", "[James Cameron] | \n", "
1 | \n", "285 | \n", "Pirates of the Caribbean: At World's End | \n", "[Captain, Barbossa,, long, believed, to, be, d... | \n", "[Adventure, Fantasy, Action] | \n", "[Johnny Depp, Orlando Bloom, Keira Knightley] | \n", "[ocean, drug abuse, exotic island, east india ... | \n", "[Gore Verbinski] | \n", "
2 | \n", "206647 | \n", "Spectre | \n", "[A, cryptic, message, from, Bond’s, past, send... | \n", "[Action, Adventure, Crime] | \n", "[Daniel Craig, Christoph Waltz, Léa Seydoux] | \n", "[spy, based on novel, secret agent, sequel, mi... | \n", "[Sam Mendes] | \n", "
3 | \n", "49026 | \n", "The Dark Knight Rises | \n", "[Following, the, death, of, District, Attorney... | \n", "[Action, Crime, Drama, Thriller] | \n", "[Christian Bale, Michael Caine, Gary Oldman] | \n", "[dc comics, crime fighter, terrorist, secret i... | \n", "[Christopher Nolan] | \n", "
4 | \n", "49529 | \n", "John Carter | \n", "[John, Carter, is, a, war-weary,, former, mili... | \n", "[Action, Adventure, Science Fiction] | \n", "[Taylor Kitsch, Lynn Collins, Samantha Morton] | \n", "[based on novel, mars, medallion, space travel... | \n", "[Andrew Stanton] | \n", "
\n", " | movie_id | \n", "title | \n", "overview | \n", "genres | \n", "cast | \n", "keywords | \n", "crew | \n", "tags | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "19995 | \n", "Avatar | \n", "[In, the, 22nd, century,, a, paraplegic, Marin... | \n", "[Action, Adventure, Fantasy, ScienceFiction] | \n", "[SamWorthington, ZoeSaldana, SigourneyWeaver] | \n", "[cultureclash, future, spacewar, spacecolony, ... | \n", "[JamesCameron] | \n", "[In, the, 22nd, century,, a, paraplegic, Marin... | \n", "
1 | \n", "285 | \n", "Pirates of the Caribbean: At World's End | \n", "[Captain, Barbossa,, long, believed, to, be, d... | \n", "[Adventure, Fantasy, Action] | \n", "[JohnnyDepp, OrlandoBloom, KeiraKnightley] | \n", "[ocean, drugabuse, exoticisland, eastindiatrad... | \n", "[GoreVerbinski] | \n", "[Captain, Barbossa,, long, believed, to, be, d... | \n", "
2 | \n", "206647 | \n", "Spectre | \n", "[A, cryptic, message, from, Bond’s, past, send... | \n", "[Action, Adventure, Crime] | \n", "[DanielCraig, ChristophWaltz, LéaSeydoux] | \n", "[spy, basedonnovel, secretagent, sequel, mi6, ... | \n", "[SamMendes] | \n", "[A, cryptic, message, from, Bond’s, past, send... | \n", "
3 | \n", "49026 | \n", "The Dark Knight Rises | \n", "[Following, the, death, of, District, Attorney... | \n", "[Action, Crime, Drama, Thriller] | \n", "[ChristianBale, MichaelCaine, GaryOldman] | \n", "[dccomics, crimefighter, terrorist, secretiden... | \n", "[ChristopherNolan] | \n", "[Following, the, death, of, District, Attorney... | \n", "
4 | \n", "49529 | \n", "John Carter | \n", "[John, Carter, is, a, war-weary,, former, mili... | \n", "[Action, Adventure, ScienceFiction] | \n", "[TaylorKitsch, LynnCollins, SamanthaMorton] | \n", "[basedonnovel, mars, medallion, spacetravel, p... | \n", "[AndrewStanton] | \n", "[John, Carter, is, a, war-weary,, former, mili... | \n", "
\n", " | movie_id | \n", "title | \n", "tags | \n", "
---|---|---|---|
0 | \n", "19995 | \n", "Avatar | \n", "In the 22nd century, a paraplegic Marine is di... | \n", "
1 | \n", "285 | \n", "Pirates of the Caribbean: At World's End | \n", "Captain Barbossa, long believed to be dead, ha... | \n", "
2 | \n", "206647 | \n", "Spectre | \n", "A cryptic message from Bond’s past sends him o... | \n", "
3 | \n", "49026 | \n", "The Dark Knight Rises | \n", "Following the death of District Attorney Harve... | \n", "
4 | \n", "49529 | \n", "John Carter | \n", "John Carter is a war-weary, former military ca... | \n", "