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...

The hybrid system can be built as follows:

  1. First, load the dataset:
> data("MovieLense") 
  1. Filter out the dataset with relevant users (namely, users who have rated above 50 movies):
> MovieLense50 <- MovieLense[rowCounts(MovieLense) >50,]
  1. Split the data into training and test sets:
> train <- MovieLense50[1:100] 
> test <- MovieLense50[101:105] 
  1. Build the hybrid recommender system using multiple models together and check the model:
> hybrid_recom <- HybridRecommender( 
  Recommender(train, method = "UBCF"), 
  Recommender(train, method = "RANDOM"), 
  weights = c(.7,.3) 
) 
 
> getModel(hybrid_recom) 
  1. Next, predict the hybrid model on test data to show the top 10 (using n=10) movies for five users:
> as(predict(hybrid_recom, test, ...

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