Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building a Recommendation System with R

You're reading from  Building a Recommendation System with R

Product type Book
Published in Sep 2015
Publisher
ISBN-13 9781783554492
Pages 158 pages
Edition 1st Edition
Languages

Preparing the data to evaluate the models


To evaluate models, you need to build them with some data and test them on some other data. This chapter will show you how to prepare the two sets of data. The recommenderlab package contains prebuilt tools that help in this task.

The target is to define two datasets, which are as follows:

  • Training set: These are the models from which users learn

  • Testing set: These are the models that users apply and test

In order to evaluate the models, we need to compare the recommendations with the user preferences. In order to do so, we need to forget about some user preferences in the test set and see whether the techniques are able to identify them. For each user in the test set, we ignore some purchases and build the recommendations based on the others. Let's load the packages:

library(recommenderlab)
library(ggplot2)

The data-set that we will use is called MovieLense. Let's define ratings_movies containing only the most relevant users and movies:

data(MovieLense...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}