Book Image

Building a Recommendation System with R

Book Image

Building a Recommendation System with R

Overview of this book

Table of Contents (13 chapters)
Building a Recommendation System with R
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
References
Index

Building the model


This section will show you how to build a recommendation model using item descriptions and user purchases. The model combines item-based collaborative filtering with some information about the items. We will include the item description using a monolithic hybrid system with feature combination. The recommender will learn from the two data sources in two separate stages.

Following the approach described in Chapter 3, Recommender Systems, let's split the data into the training and the test set:

which_train <- sample(x = c(TRUE, FALSE),size = nrow(ratings_matrix),replace = TRUE,prob = c(0.8, 0.2))recc_data_train <- ratings_matrix[which_train, ]
recc_data_test <- ratings_matrix[!which_train, ]

Now, we can build an IBCF model using Recommender. Since the rating matrix is binary, we will set the distance method to Jaccard. For more details, look at the Collaborative filtering on binary data section in Chapter 3, Recommender Systems. The remaining parameters are left...