Search code examples
rsparse-matrixrecommendation-enginecollaborative-filtering

R Recommenderlab - Getting the user_id out the RealRatingMatrix containing UBCF recommendations


Recommenderlab - Getting the user_id out the RealRatingMatrix containing UBCF recommendations. I'm trying to use recommenderlab (with RSTUDIO) to get recommendations.When I'm using UBCF I can't extract the user id out of the realRatingMatrix containing the predictions, although I can do it with POPULAR and IBCF methods.That's the sample code I'm using:

library(recommenderlab)
data(Jester5k)
Jester5k
r <- sample(Jester5k, 1000)   
rec_pop <- Recommender(Jester5k[1:1000], method = "POPULAR")
#rec_pop
recom_pop <- predict(rec_pop, Jester5k[1001:1002], n=100, type="ratings")
#recom_pop
as(recom_pop, "matrix")
getList(recom_pop,decode=TRUE,ratings=TRUE)
getData.frame(recom_pop,decode=TRUE,ratings=TRUE)

user_id and item_id are displayed correctly with each of the 3 alternatives

rec_ib <- Recommender(r[1:100],method="IBCF", param=list(normalize = "Z-score",method="Jaccard",minRating=1))
#rec_ib
recom_ib <- predict(rec_ib, Jester5k[1001:1002], n=100, type="ratings")
#recom_ib    
as(recom_ib, "matrix")
getList(recom_ib,decode=TRUE,ratings=TRUE)
getData.frame(recom_ib,decode=TRUE,ratings=TRUE)

user_id and item_id are displayed correctly with each of the 3 alternatives

rec_ub <- Recommender(r[1:400],method="UBCF", param=list(normalize = "Z-score",method="Cosine",nn=5, minRating=1))
#rec_ub
recom_ub <- predict(rec_ub, Jester5k[1001:1002], n=100, type="ratings")
#recom_ub   
as(recom_ub, "matrix")
getList(recom_ub,decode=TRUE,ratings=TRUE)
getData.frame(recom_ub,decode=TRUE,ratings=TRUE)

item _id is displayed correctly , but I can't get the user_id with none of the 3 alternatives... How can I get the user_id ?Am I doing something wrong? I'll appreciate your help to spot my mistake.


Solution

  • This bug seems to be fixed now.