November 2017
Beginner to intermediate
366 pages
7h 59m
English
The first step is to obtain the ratings matrix. The recommenderlab expects the user rating matrix to be stored as either binaryRatingsMatrix or realRatingsMatrix.
The realRatingsmatrix s3 class has a slot called data where the actual ratings matrix is stored in a compressed format. The getRatingMatrix function is an easy way to extract this matrix from the s3 class.
Let us extract the ratings matrix from our dataset:
> data <- sample(Jester5k, 1500)> ratings.mat <- getRatingMatrix(data)> str(ratings.mat)Formal class 'dgCMatrix' [package "Matrix"] with 6 slots ..@ i : int [1:108531] 0 1 2 3 7 8 9 10 11 12 ... ..@ p : int [1:101] 0 984 2083 3083 4026 5525 6743 8243 9743 10691 ... ..@ Dim : int [1:2] 1500 100 ..@ Dimnames:List ...
Read now
Unlock full access