The following code gives me a warning which keeps on printing infinite times. What should I change in my code to prevent this?
lambda_list <- seq(0,10,0.2)
rmses <- sapply(lambda_list, function(l){
b_i <- train %>% group_by(movieId) %>%
summarise(b_i = sum(rating - mu)/(n()+l))
b_y <- train %>% left_join(b_i, by="movieId") %>%
group_by(userId) %>% summarise(b_y = sum(rating - b_i - mu)/(n()+l))
predicted_ratings <- test %>%
left_join(b_i, by = "movieId") %>%
left_join(b_y, by = "userId") %>%
mutate(pred = mu + b_i + b_y) %>% .$pred
return(RMSE(test$rating, predicted_ratings))
The output: