Description Objects from the Class Slots Extends Methods See Also Examples
A matrix containing ratings (typically 1-5 stars, etc.).
Objects can be created by calls of the form new("realRatingMatrix", data = m)
, where m
is sparse matrix of class
dgCMatrix
in package Matrix
or by coercion from a regular matrix, a data.frame containing user/item/rating triplets as rows, or
a sparse matrix in triplet form (dgTMatrix
in package Matrix).
data
:Object of class
"dgCMatrix"
, a sparse matrix
defined in package Matrix. Note that this matrix drops NAs instead
of zeroes. Operations on "dgCMatrix"
potentially will delete
zeroes.
normalize
:NULL
or a list with normalizaton factors.
Class "ratingMatrix"
, directly.
signature(from = "matrix", to = "realRatingMatrix")
signature(from = "realRatingMatrix", to = "matrix")
signature(from = "data.frame", to = "realRatingMatrix")
:
coercion from a data.frame with three columns.
Col 1 contains user ids, col 2 contains item ids and
col 3 contains ratings.
signature(from = "realRatingMatrix", to = "data.frame")
: produces user/item/rating triplets.
signature(from = "realRatingMatrix", to = "dgTMatrix")
signature(from = "dgTMatrix", to = "realRatingMatrix")
signature(from = "realRatingMatrix", to = "dgCMatrix")
signature(from = "dgCMatrix", to = "realRatingMatrix")
signature(from = "realRatingMatrix", to = "ngCMatrix")
signature(x = "realRatingMatrix")
: create a
"binaryRatingMatrix"
by setting all ratings larger or equal to
the argument minRating
as 1 and all others to 0.
signature(x = "realRatingMatrix")
: removes
all ratings in x
for which ratings are available in
the realRatingMatrix (of same dimensions as x
)
passed as the argument known
.
signature(x = "realRatingMatrix")
: calculate
the standard deviation of ratings for rows (users).
signature(x = "realRatingMatrix")
: calculate
the standard deviation of ratings for columns (items).
See ratingMatrix
inherited methods,
binaryRatingMatrix
,
topNList
,
getList
and getData.frame
.
Also see dgCMatrix
,
dgTMatrix
and
ngCMatrix
in Matrix.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## create a matrix with ratings
m <- matrix(sample(c(NA,0:5),100, replace=TRUE, prob=c(.7,rep(.3/6,6))),
nrow=10, ncol=10, dimnames = list(
user=paste('u', 1:10, sep=''),
item=paste('i', 1:10, sep='')
))
m
## coerce into a realRatingMAtrix
r <- as(m, "realRatingMatrix")
r
## get some information
dimnames(r)
rowCounts(r)
colCounts(r)
rowMeans(r)
## histogram of ratings
hist(getRatings(r), breaks="FD")
## inspect a subset
image(r[1:5,1:5])
## coerce it back to see if it worked
as(r, "matrix")
## coerce to data.frame (user/item/rating triplets)
as(r, "data.frame")
## binarize into a binaryRatingMatrix with all 4+ rating a 1
b <- binarize(r, minRating=4)
b
as(b, "matrix")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.