The objective of this assignment is to implement a Global Baseline Estimate recommendation system in R using the last assignment’s movie rating data that I’d collected and provided spreadsheet algorithm Movie Ratings XLSX . There are two types of recommendation system algorithm, personalized and non personalized.
In this assignment, we are going to use “Global Baseline Estimate”.
Baseline Estimate=Global Mean+User Bias+Item Bias
Global Mean: The overall average rating across all items and all users in the dataset.
User Bias: How much a specific user’s rating tend to deviate from the global average.
Item Bias: How much a specific item’s rating deviate from the global average.
Global Baseline Estimate (often called a baseline predictor) is a non-personalized algorithm used in recommender system to predict how a user would rate a specific item.
Approach
First, I will reformat the TV episode ratings data to a format similar to the provided movie ratings spreadsheet.
Then, I will calculate each user’s average TV episode rating in R and store the results in a user_avg column. I will also calculate the global mean.
Next, I will calculate the average rating for each TV episode in R and store the results in a episode_avg column at the end of the records.
Then, I will identify any TV episode that is missing a rating for a particular user. For each missing rating, I will use the Global Baseline Estimate formula to calculate a predicted rating based on the available user ratings, episode ratings, and overall average rating. Then I’ll make sure the calculations are valid and reproducible.
Anticipated Challenges
Since I only have five users rating six TV episodes, there is a chance that some episodes will not be rated by certain users. This may result in missing ratings and could potentially introduce bias into the analysis. The small number of users may also make the average ratings less representative.
Code
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.0 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.3 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# A tibble: 30 × 4
# Groups: user [5]
user tv_episodes rating user_avg
<chr> <chr> <int> <dbl>
1 Tenzin Squid Game 5 4.2
2 Tenzin Emily in Paris 4 4.2
3 Tenzin Ginny&Georgia 3 4.2
4 Tenzin Brigerton 4 4.2
5 Tenzin Wednesday 5 4.2
6 Tenzin Stranger Things NA 4.2
7 Laura Squid Game 4 4.4
8 Laura Emily in Paris 5 4.4
9 Laura Ginny&Georgia 4 4.4
10 Laura Brigerton 5 4.4
# ℹ 20 more rows
Added a “user_avg” column that shows each user’s average rating for the episodes they rated.
Based on the global baseline estimate recommendation system, Jose’s 4.65 rating for Squid Game stands out as a must-watch and highly recommended TV series.