{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Netflix Content Recommendation System\n", "This notebook implements a hybrid recommendation system for Netflix movies and TV shows using:\n", "1. Content-based filtering with TF-IDF vectorization and cosine similarity\n", "2. Collaborative filtering based on user preferences\n", "3. Node representation learning for enhanced content understanding" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "from sklearn.metrics.pairwise import cosine_similarity\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "from scipy.sparse.linalg import svds\n", "import networkx as nx\n", "from node2vec import Node2Vec" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Data Loading and Preprocessing" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | show_id | \n", "type | \n", "title | \n", "director | \n", "cast | \n", "country | \n", "date_added | \n", "release_year | \n", "rating | \n", "duration | \n", "listed_in | \n", "description | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "s1 | \n", "Movie | \n", "Dick Johnson Is Dead | \n", "Kirsten Johnson | \n", "NaN | \n", "United States | \n", "September 25, 2021 | \n", "2020 | \n", "PG-13 | \n", "90 min | \n", "Documentaries | \n", "As her father nears the end of his life, filmm... | \n", "
1 | \n", "s2 | \n", "TV Show | \n", "Blood & Water | \n", "NaN | \n", "Ama Qamata, Khosi Ngema, Gail Mabalane, Thaban... | \n", "South Africa | \n", "September 24, 2021 | \n", "2021 | \n", "TV-MA | \n", "2 Seasons | \n", "International TV Shows, TV Dramas, TV Mysteries | \n", "After crossing paths at a party, a Cape Town t... | \n", "
2 | \n", "s3 | \n", "TV Show | \n", "Ganglands | \n", "Julien Leclercq | \n", "Sami Bouajila, Tracy Gotoas, Samuel Jouy, Nabi... | \n", "NaN | \n", "September 24, 2021 | \n", "2021 | \n", "TV-MA | \n", "1 Season | \n", "Crime TV Shows, International TV Shows, TV Act... | \n", "To protect his family from a powerful drug lor... | \n", "
3 | \n", "s4 | \n", "TV Show | \n", "Jailbirds New Orleans | \n", "NaN | \n", "NaN | \n", "NaN | \n", "September 24, 2021 | \n", "2021 | \n", "TV-MA | \n", "1 Season | \n", "Docuseries, Reality TV | \n", "Feuds, flirtations and toilet talk go down amo... | \n", "
4 | \n", "s5 | \n", "TV Show | \n", "Kota Factory | \n", "NaN | \n", "Mayur More, Jitendra Kumar, Ranjan Raj, Alam K... | \n", "India | \n", "September 24, 2021 | \n", "2021 | \n", "TV-MA | \n", "2 Seasons | \n", "International TV Shows, Romantic TV Shows, TV ... | \n", "In a city of coaching centers known to train I... | \n", "
\n", " | title | \n", "type | \n", "similarity_score | \n", "description | \n", "genres | \n", "score_components | \n", "
---|---|---|---|---|---|---|
0 | \n", "Five Elements Ninjas | \n", "Movie | \n", "0.700000 | \n", "When five ninjas whose fighting styles are bas... | \n", "Action & Adventure, International Movies | \n", "{'content': 1.0, 'node_embeddings': 0} | \n", "
1 | \n", "Earth's Natural Wonders: Life at the Extremes | \n", "TV Show | \n", "0.542616 | \n", "From the Arctic to the Outback, humans battle ... | \n", "British TV Shows, Docuseries, Science & Nature TV | \n", "{'content': 0.7751661835752652, 'node_embeddin... | \n", "
2 | \n", "Forces of Nature | \n", "TV Show | \n", "0.515814 | \n", "This dynamic series spans the globe to explain... | \n", "British TV Shows, Docuseries, Science & Nature TV | \n", "{'content': 0.7368765426984699, 'node_embeddin... | \n", "
3 | \n", "Big Timber | \n", "TV Show | \n", "0.510249 | \n", "A no-nonsense logger and his loyal crew battle... | \n", "International TV Shows, Reality TV | \n", "{'content': 0.7289268059265909, 'node_embeddin... | \n", "
4 | \n", "Stranger Things | \n", "TV Show | \n", "0.495280 | \n", "When a young boy vanishes, a small town uncove... | \n", "TV Horror, TV Mysteries, TV Sci-Fi & Fantasy | \n", "{'content': 0.7075426826101006, 'node_embeddin... | \n", "
5 | \n", "SHOT! The Psycho-Spiritual Mantra of Rock | \n", "Movie | \n", "0.474878 | \n", "Aptly named iconic rock photographer Mick Rock... | \n", "Documentaries, Music & Musicals | \n", "{'content': 0.6783969969392141, 'node_embeddin... | \n", "
6 | \n", "Malibu Rescue: The Series | \n", "TV Show | \n", "0.470982 | \n", "On the heels of Junior Rescue training, Team F... | \n", "Kids' TV, TV Action & Adventure, TV Comedies | \n", "{'content': 0.6728318789515935, 'node_embeddin... | \n", "
7 | \n", "Kanika | \n", "Movie | \n", "0.452191 | \n", "A doctor and his colleagues who use sex-determ... | \n", "Horror Movies, International Movies, Thrillers | \n", "{'content': 0.6459868562691757, 'node_embeddin... | \n", "
8 | \n", "Family Blood | \n", "Movie | \n", "0.445207 | \n", "A former addict moves to a new city with her c... | \n", "Horror Movies | \n", "{'content': 0.6360106514614375, 'node_embeddin... | \n", "
9 | \n", "An American Tail: The Mystery of the Night Mon... | \n", "Movie | \n", "0.439914 | \n", "When a monster goes on a mouse-napping spree i... | \n", "Children & Family Movies | \n", "{'content': 0.6284485470424953, 'node_embeddin... | \n", "