O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Here is how we proceed with collaborating filtering systems:

  1. First, define ratings_movies, the matrix containing users who have rated at least 50 movies and the movies that have been watched at least 100 times:
> ratings_movies <- MovieLense[rowCounts(MovieLense) > 50, 
colCounts(MovieLense) > 100] 
  1. Now split the ratings_movies matrix into training and test sets using an 80/20 ratio:
> which_train <- sample(x = c(TRUE, FALSE), size = nrow(ratings_movies), 
replace = TRUE, prob = c(0.8, 0.2)) 
> recc_data_train <- ratings_movies[which_train, ] 
> recc_data_test <- ratings_movies[!which_train, ] 
The Recommenderlab package provides you with the evaluationScheme function to perform advance splitting of datasets. Refer to the  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required