In this code:-
top10_prediction_linear <- test_set %>%
left_join(b_i, by = "movieId") %>%
left_join(b_u, by = "userId") %>%
mutate(y_hat = mu + b_i + b_u) %>%
arrange(desc(y_hat)) %>%
select(title) %>%
unique() %>%
slice_head(n = 10)
top10_prediction_linear_df <- data.frame(Title = top10_prediction_linear,
Rating = rep(NA, 10),
Count = rep(NA, 10))
for (i in 1:10) {
indexes <- which(test_set$title == as.character(top10_prediction_linear[i]))
top10_prediction_linear_df$Rating[i] <- mean(test_set$rating[indexes])
top10_prediction_linear_df$Count[i] <- sum(
test_set$title == as.character(top10_prediction_linear[i])
)
}
print(top10_prediction_linear_df)
I got this error:-
Error in UseMethod("left_join") : no applicable method for 'left_join' applied to an object of class "c('matrix', 'array', 'integer', 'numeric')"
Help me to remove this error and run my code