Data Programming

Homework 4

Author

Mirko Dugajlic

Published

May 15, 2024

Introduction

About

Netflix stands as a leading force in the realm of media and video streaming. With a staggering array of over 8,000 movies and TV shows accessible on their platform, as of mid-2021, their global subscriber count exceeds 200 million. This tabulated dataset comprehensively catalogues all offerings on Netflix, including vital details such as cast, directors, ratings, release year, duration, and more.

Why this topic?

  • Firstly, it provides a rich source of information about user preferences and viewing habits, which are essential for building accurate recommendation models.

  • Secondly, the Netflix movies dataset enables the development and evaluation of advanced recommendation algorithms and machine learning models. With access to detailed information about movie genres, ratings, release years, crew and cast, and user interactions, etc. scientists can experiment with various algorithms such as collaborative filtering, content-based filtering, and hybrid methods to improve the accuracy and relevance of recommendations.

Moreover, by continually updating and expanding the dataset, we contribute to the ongoing research and development efforts in the field of recommendation systems. As streaming platforms like Netflix evolve and introduce new content, it becomes imperative to adapt recommendation algorithms to accommodate these changes and ensure that users receive personalized and engaging recommendations.

Dataset Overview

About

The Netflix Titles dataset is a comprehensive compilation of movies and TV shows available on Netflix, covering various aspects such as the title type, director, cast, country of production, release year, rating, duration, genres (listed in), and a brief description. This dataset is instrumental for analyzing trends in Netflix content, understanding genre popularity, and examining the distribution of content across different regions and time periods.

Key Details

Dataset: Netflix Dataset

Total Entries: The dataset contains 8,809 entries, each representing a unique movie or TV show.

Columns: There are 12 columns in the dataset:

  1. show_id: A unique identifier for each title.

  2. type: The category of the title, which is either ‘Movie’ or ‘TV Show’.

  3. title: The name of the movie or TV show.

  4. director: The director(s) of the movie or TV show. (Contains null values for some entries, especially TV shows where this information might not be applicable.)

  5. cast: The list of main actors/actresses in the title. (Some entries might not have this information.)

  6. country: The country or countries where the movie or TV show was produced.

  7. date_added: The date the title was added to Netflix.

  8. release_year: The year the movie or TV show was originally released.

  9. rating: The age rating of the title.

  10. duration: The duration of the title, in minutes for movies and seasons for TV shows.

  11. listed_in: The genres the title falls under.

  12. description: A brief summary of the title.

Visual

library(readxl)
library(tibble)
library(dplyr)
df <- read.csv("./files/netflix_titles.csv")
columns_to_delete <- grep("^X", names(df))
# Reason for deleting columns is that it makes additional columns after reading files. 
# Columns are called X, X.1, X.2 and so on.
df <- df[, -columns_to_delete]
as_tibble(df)
# A tibble: 8,809 × 12
   show_id type    title   director cast  country date_added release_year rating
   <chr>   <chr>   <chr>   <chr>    <chr> <chr>   <chr>             <int> <chr> 
 1 s1      Movie   Dick J… "Kirste… ""    "Unite… September…         2020 PG-13 
 2 s2      TV Show Blood … ""       "Ama… "South… September…         2021 TV-MA 
 3 s3      TV Show Gangla… "Julien… "Sam… ""      September…         2021 TV-MA 
 4 s4      TV Show Jailbi… ""       ""    ""      September…         2021 TV-MA 
 5 s5      TV Show Kota F… ""       "May… "India" September…         2021 TV-MA 
 6 s6      TV Show Midnig… "Mike F… "Kat… ""      September…         2021 TV-MA 
 7 s7      Movie   My Lit… "Robert… "Van… ""      September…         2021 PG    
 8 s8      Movie   Sankofa "Haile … "Kof… "Unite… September…         1993 TV-MA 
 9 s9      TV Show The Gr… "Andy D… "Mel… "Unite… September…         2021 TV-14 
10 s10     Movie   The St… "Theodo… "Mel… "Unite… September…         2021 PG-13 
# ℹ 8,799 more rows
# ℹ 3 more variables: duration <chr>, listed_in <chr>, description <chr>

Analysis

Error checking

\[ \begin{equation} RMSE = \sqrt{\sum_{i=1}^{n} \frac{(\hat y_i - y_i)^2} {n}} \end{equation} \] Here we can see how to calculate RMSE (Root Mean Square) which is either one of two closely related and frequently used measures of the differences between true or predicted values on the one hand and observed values or an estimator on the other. Variables used in the formula are:

  • \(\hat{y}\) - predicted values

  • \(y\) - observed values

  • \(n\) - number of observations

Movies and TV Shows average duration over years

# make a plot with years on x axis and number of movies for decades\
library(tidyverse)


# Change to numeric value
df$year <- as.numeric(df$release_year) # Extract the year

# Duration extraction
df$duration_num <- as.numeric(str_extract(df$duration, "\\d+"))
df_groupedby_type <- df %>%
  group_by(.$type)


# Filter out the Movies and group by year
df_movies <- df %>%
  filter(type == "Movie") %>%
  group_by(year)

df_shows <- df %>%
  filter(type == "TV Show") %>%
  group_by(year)

# Calculate the average duration of movies and series per year
df_avg_movie_duration <- df_movies %>%
  summarise(avg_duration = mean(duration_num, na.rm = TRUE))

df_avg_series_duration <- df_shows %>%
  summarise(avg_duration = mean(duration_num, na.rm = TRUE))
# Create the plot fot movies
ggplot(df_avg_movie_duration, aes(x=year, y=avg_duration)) +
  geom_line() +
  scale_x_continuous(breaks = seq(min(df_avg_movie_duration$year), max(df_avg_movie_duration$year), by = 7)) +
  labs(x="Year", y="Average Duration (mins)", title="Average Movie Duration Over Time") +
  theme_minimal()

Figure 1: Movies
# Create the plot for series
ggplot(df_avg_series_duration, aes(x=year, y=avg_duration)) +
  geom_line() +
  scale_x_continuous(breaks = seq(min(df_avg_series_duration$year), max(df_avg_series_duration$year), by = 7)) +
  labs(x="Year", y="Average Duration (seasons)", title="Average Series Duration Over Time") +
  theme_minimal()

Figure 2: TV Show

Discussion

Figure 1 depicts how the average duration of movies (in minutes) has expanded dramatically in period between 1942 until around1965. From there, the length of each movie varies between 100 and 150 minutes. In the previous 20 years, there has been a tiny but consistent drop in duration.

Figure 2 does not show anything specific, but it does demonstrate how the duration represented in seasons is not a useful way to express the length of TV shows, if it is the only one.

Top 5

Table 1: Longest movies and their genres
Title Genres Length
Black Mirror: Bandersnatch Dramas, International, Sci-Fi & Fantasy 312 min
Headspace: Unwind Your Mind Documentaries 273 min
The School of Mischief Comedies, Dramas, International 257 min
No Longer Kids Comedies, Dramas, International 237 min
Lock Your Girls Comedies, International, Romantic 233 min

In Table 1 we can see top 5 longest movies from the dataset listed in descending order. On the other side in Table 2 we can see top 5 longest Tv Shows in terms of seasons.

top_n_tvshows <- df %>% 
  filter(type == "TV Show") %>%
  arrange(desc(duration_num))

# Get first 5 rows
top_n_tvshows <- head(top_n_tvshows, n = 5) 

# Display top N movies as a table
knitr::kable(top_n_tvshows[, c("title", "listed_in", "duration")],
      col.names = c( "Title","Genre", "Duration"))
Table 2: Longest TV Shows and their genres
Title Genre Duration
Grey’s Anatomy Romantic TV Shows, TV Dramas 17 Seasons
Supernatural Classic & Cult TV, TV Action & Adventure, TV Horror 15 Seasons
NCIS Crime TV Shows, TV Dramas, TV Mysteries 15 Seasons
Heartland TV Dramas 13 Seasons
COMEDIANS of the world Stand-Up Comedy & Talk Shows, TV Comedies 13 Seasons

Books

One of the popular books and well-written ones is (Frey 2021). The content is about algorithmic recommender systems, deployed by media companies to suggest content based on users’ viewing histories, have inspired hopes for personalized, curated media but also dire warnings of filter bubbles and media homogeneity. All these facts were written in Section 1.

Articles

References

Amatriain, Xavier, and Justin Basilico. 2015. “Recommender Systems in Industry: A Netflix Case Study.” In, 385–419. https://doi.org/10.1007/978-1-4899-7637-6_11.
Chiny, Mohamed, Marouane Chihab, Omar Bencharef, and Chihab Younes. 2022. “Netflix Recommendation System Based on TF-IDF and Cosine Similarity Algorithms.” In, 15–20. https://doi.org/10.5220/0010727500003101.
Frey, Mattias. 2021. Algorithms, Film Choice, and the History of Taste. Berkeley: University of California Press. https://doi.org/doi:10.1525/9780520382022.