Required Library

library(readxl) library(dplyr)

movie_rating<-read_excel("F:\\CUNY masters\\extra credit assignment 607\\607 2nd extra credit\\movie_rating.xlsx",sheet=1,range="A1:G6",
              col_name=TRUE,col_types=NULL)
movie_rating 
## # A tibble: 5 × 7
##   Critic  Barbarian Funnypage Holdmetight  Nope  Prey Theterritory
##   <chr>       <dbl>     <dbl>       <dbl> <dbl> <dbl>        <dbl>
## 1 Monir           3         5           4     1     2           NA
## 2 Karim           2         3           4     5    NA            1
## 3 Joseph          4         5           3     2    NA           NA
## 4 Arony           3         4           5     1     3            2
## 5 Prakash         5         3           2     4    NA            1
movie_rating1<-movie_rating[c("Barbarian","Funnypage","Holdmetight","Nope","Prey","Theterritory")]
movie_rating1
## # A tibble: 5 × 6
##   Barbarian Funnypage Holdmetight  Nope  Prey Theterritory
##       <dbl>     <dbl>       <dbl> <dbl> <dbl>        <dbl>
## 1         3         5           4     1     2           NA
## 2         2         3           4     5    NA            1
## 3         4         5           3     2    NA           NA
## 4         3         4           5     1     3            2
## 5         5         3           2     4    NA            1
movie_rating1<-movie_rating1 %>% mutate(user_avg=rowMeans(movie_rating1,na.rm=TRUE,dims=1))
movie_rating1
## # A tibble: 5 × 7
##   Barbarian Funnypage Holdmetight  Nope  Prey Theterritory user_avg
##       <dbl>     <dbl>       <dbl> <dbl> <dbl>        <dbl>    <dbl>
## 1         3         5           4     1     2           NA      3  
## 2         2         3           4     5    NA            1      3  
## 3         4         5           3     2    NA           NA      3.5
## 4         3         4           5     1     3            2      3  
## 5         5         3           2     4    NA            1      3
movie_avg<-colMeans(movie_rating[sapply(movie_rating, is.numeric)],na.rm=TRUE)
movie_avg
##    Barbarian    Funnypage  Holdmetight         Nope         Prey Theterritory 
##     3.400000     4.000000     3.600000     2.600000     2.500000     1.333333
mean_movie<-mean(movie_avg)
mean_movie
## [1] 2.905556
movie_avg_minus_mean_movie<-movie_avg-mean_movie
movie_avg_minus_mean_movie
##    Barbarian    Funnypage  Holdmetight         Nope         Prey Theterritory 
##    0.4944444    1.0944444    0.6944444   -0.3055556   -0.4055556   -1.5722222
user_avg_minus_mean_movie<-movie_rating1$user_avg-mean_movie
user_avg_minus_mean_movie
## [1] 0.09444444 0.09444444 0.59444444 0.09444444 0.09444444
movie<-c("Barbarian","Funnypage","Holdmetight","Nope","Prey","Theterritory")
user_avg<-movie_rating1$user_avg
movie_avg
##    Barbarian    Funnypage  Holdmetight         Nope         Prey Theterritory 
##     3.400000     4.000000     3.600000     2.600000     2.500000     1.333333
df_new <- cbind(movie_rating,user_avg,user_avg_minus_mean_movie)
df_new
##    Critic Barbarian Funnypage Holdmetight Nope Prey Theterritory user_avg
## 1   Monir         3         5           4    1    2           NA      3.0
## 2   Karim         2         3           4    5   NA            1      3.0
## 3  Joseph         4         5           3    2   NA           NA      3.5
## 4   Arony         3         4           5    1    3            2      3.0
## 5 Prakash         5         3           2    4   NA            1      3.0
##   user_avg_minus_mean_movie
## 1                0.09444444
## 2                0.09444444
## 3                0.59444444
## 4                0.09444444
## 5                0.09444444
df1<-data.frame(movie_avg,movie_avg_minus_mean_movie)
df1
##              movie_avg movie_avg_minus_mean_movie
## Barbarian     3.400000                  0.4944444
## Funnypage     4.000000                  1.0944444
## Holdmetight   3.600000                  0.6944444
## Nope          2.600000                 -0.3055556
## Prey          2.500000                 -0.4055556
## Theterritory  1.333333                 -1.5722222

Finding rate by Global Baseline Estimate

Question1: How would Monir rate Theterritory? Question2: How would Karim rate Prey? Question3: How would Joseph rate Prey and Theterritory? Question4: How would Prakash rate Prey?

**General Formula: Global Baseline Estimate = Mean Movie Rating + movie rating relative to average + Critic’s rating relative to average.

Monir_rating_for_Theterritory<-2.905556 -1.5722222+0.09444444
Monir_rating_for_Theterritory
## [1] 1.427778
Karim_rating_for_Prey<-2.905556 -0.4055556+0.09444444
Karim_rating_for_Prey
## [1] 2.594445
Joseph_rating_for_Prey<-2.905556 -0.4055556+0.59444444
Joseph_rating_for_Prey
## [1] 3.094445
Joseph_rating_for_Theterritory<-2.905556-1.5722222+0.59444444
Joseph_rating_for_Theterritory
## [1] 1.927778
Prakash_rating_for_Prey<-2.905556-0.4055556+0.09444444
Prakash_rating_for_Prey
## [1] 2.594445

#Above 4 questions answers are presented below in tabular form

unseen_movie_rating<-data.frame(Monir_rating_for_Theterritory,Karim_rating_for_Prey,Joseph_rating_for_Prey,Joseph_rating_for_Theterritory,Prakash_rating_for_Prey)
unseen_movie_rating
##   Monir_rating_for_Theterritory Karim_rating_for_Prey Joseph_rating_for_Prey
## 1                      1.427778              2.594445               3.094445
##   Joseph_rating_for_Theterritory Prakash_rating_for_Prey
## 1                       1.927778                2.594445

**Recommending Prey for Karim