How to convert a ratings data frame to a ratings matrix in R

r
recommender

#1

hello,

I am trying to implement recommeders in R using:

recommenderRegistry$get_entries(datatype = "binaryRatingMatrix")
reco = as.matrix(df)
reco = as(reco,"binaryRatingMatrix")
scheme = evaluationScheme(reco,method = "split",train = 0.9,given = 1)
scheme

algorithms <- list(
  "random items" <- list(name = "RANDOM",param = list(normalize = 'Z-score')),
  "popular items" = list(name = "POPULAR",param = list(normalize = 'Z-score')),
  "user-based CF" = list(name = "UBCF",param = list(nn = 50)),
  "item-based CF" = list(name = "IBCF"),
  "AR based RS" = list(name = "AR"))

results <- evaluate(scheme,algorithms,n = c(1,3,5,10,15,20))
plot(results,annotate = 1:4,legend = "bottomright")

Results <- Recommender(reco,method = "UBCF",parameter = list(nn = 50))

here the matrix df is a binary ratings matrix:

I have a ratings matrix from movielens:

which has 1682 unique users and it’s structure is:

Now,how do i convert it into a matrix that can be used as an input to the recommender.
Can someone please help me on this??