mhahsler/recommenderlab

when using IBCF method for top-N list,I only get n outcome(n is less than N) for some users

Closed this issue · 1 comments

when using binary data and IBCF creat a recommender,I want return a top-N list of recommendations for seven users,where N equals to 3.But for one user ,I just get two recommendations,for two users I get one recommendation,and for four users I get no recommendations.The code likes:
`library("recommenderlab")
#getData
logDataRead <- read.csv("logData.csv", header = TRUE, sep = ",", quote = """)
#add number of clicks as a column
#use ID
logDataPreID <- data.frame(logDataRead[c("UserID","ItemID")],rate = rep(1,length(logDataRead["UserUUID"])))
#coercion from data.frame to realRatingMatrix
logDataID <- as(logDataPreID, "realRatingMatrix")
logDataID
#show details
getRatingMatrix(logDataID)

#numbers of item for every user
rowCounts(logDataID)
#numbers of user for every item
colCounts(logDataID)

#return item clicked and rating for every user
as(logDataID, "list")

#change realRatingMatrix to binaryRatingMatrix
logDataID_b <- binarize(logDataID, minRating=1)
as(logDataID_b, "matrix")
as(logDataID_b, "list")
#show methods
recommenderRegistry$get_entries(dataType = "binaryRatingMatrix")

#IBCF item-based
RecoModel_b <- Recommender(logDataID_b, method = "IBCF")
getModel(RecoModel_b)

recomTopN <- predict(RecoModel_b, logDataID_b,n=3)
as(recomTopN, "list")
as(logDataID_b, "list")
as(logDataID, "list")

similarity(logDataID_b, method = "jaccard",which="items")

#UBCF user-based
RecoModel_b_UB <- Recommender(logDataID_b, method = "UBCF")
getModel(RecoModel_b_UB)

recomTopN_UB <- predict(RecoModel_b_UB, logDataID_b,n=3)
as(recomTopN_UB, "list")
as(logDataID_b, "list")
as(logDataID, "list")
#similarity between users
similarity(logDataID_b, method = "jaccard",which="users")

dissimilarity(logDataID_b, method = "jaccard",which="users")`

the data likes:
logDataPreID
UserID ItemID rate
1 u1 i1 1
2 u2 i2 1
3 u3 i3 1
4 u4 i4 1
5 u5 i5 1
6 u6 i6 1
7 u7 i7 1
8 u1 i2 1
9 u1 i5 1
10 u5 i2 1
11 u3 i7 1

the outcome of top-3 list using IBCF method likes:
as(recomTopN, "matrix")
i1 i2 i3 i4 i5 i6 i7
u1 NA NA NA NA NA NA NA
u2 0.3333333 NA NA NA 0.6666667 NA NA
u3 NA NA NA NA NA NA NA
u4 NA NA NA NA NA NA NA
u5 0.4166667 NA NA NA NA NA NA
u6 NA NA NA NA NA NA NA
u7 NA NA 0.5 NA NA NA NA

so for u2 ,I just get two recommendations--i5,i1,for two users(u5,u7) I get one recommendation(i1,i3),and for four users I get no recommendations.
However,when I use UBCF method,I can get top-3 list of recommendations for every user.
My English isn't good.I dont know whether I describe my problem clearly.
Can anyone tell me
1.The problem above is normal or abnormal. Is it a real problem?
2.The reason for the problem
3.the solutions for the problem

This can happen for IBCF when a user has already seen most of the items in the list of similar items. When you ask for 3 items, then you actually ask for a maximum of 3 items. UBCF works differently and is not affected by this.

This will happen less often if you increase k (the number of retained similar items)

> recommenderRegistry$get_entry("IBCF", dataType = "binaryRatingMatrix")
Recommender method: IBCF for binaryRatingMatrix
Description: Recommender based on item-based collaborative filtering (binary rating data).
Reference: NA
Parameters:
   k    method normalize_sim_matrix alpha
1 30 "Jaccard"                FALSE   0.5