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

Data exploration


In this section, we will explore the MovieLense dataset. For this purpose, we will use recommenderlab to build recommender systems and ggplot2 to visualize their results. Let's load the packages and the data:

library("recommenderlab")
library("ggplot2")
data(MovieLense)
class(MovieLense)
## [1] "realRatingMatrix"
## attr(,"package")
## [1] "recommenderlab"

MovieLense is a realRatingMatrix object containing a dataset about movie ratings. Each row corresponds to a user, each column to a movie, and each value to a rating.

Exploring the nature of the data

Let's take a quick look at MovieLense. As explained in the previous section, there are some generic methods that can be applied to realRatingMatrix objects. We can extract their size using dim:

dim(MovieLense)
## [1]  943 1664

There are 943 users and 1664 movies. Since realRatingMatrix is an S4 class, the components of the objects are contained in MovieLense slots. We can see all the slots using slotNames, which displays all the...