1

I have a data set, Recoset, of ratings given by users for certain product categories. I am trying to learn use the ratings given by users to predict product categories that other users may like by putting the User Based Collaborative Filtering of recommenderLab package to use, in R.

Here is the code

m <- read.csv("recoset2.csv")
rrm <-as(m,"realRatingMatrix")
rrm2 <- rrm[rowCounts(rrm)>5] #only users who have bought from more than 5 verticals (any random 5)

learn <- Recommender(rrm2,method = "UBCF")
learned <- predict(learn,rrm[2001:2010,],n=3)
learned_list <- as(learned,"list")

Now the code works perfectly fine (sometimes) as long as I am predicting for 10 users or less. But the moment I increase the number of users to 11 or more in this manner

learned <- predict(learn,rrm[2001:2020],n=3)

I am greeted by this error

Error in neighbors[, x] : incorrect number of dimensions

This error at times also props up for as low as 2 users, but never have I received this error for 1 user.

I have spent days by myself, gone through the entire recommenderLab documentation, scoured numerous sources & tutorials but debug this error. Any help in resolving this would be immensely appreciated

> user                          item                 rating
> ORG1SNQ0TV16NQP6ZB5SD9XGX1FP7 MobileCable            2
> ORG441VE999BMCTYGZ0H7HDWHGX62 OTGPendrive            2
> ORG7L1NRFQZTPDJRFXC0CQ1LXLY6E MobileScreenGuard      3
> ORGBYFYMG92YFDC043NG7PZEHEPTS MobileScreenGuard      2
> ORGLZH07SFPSFQ3RZJMCV85XKKDKE Smartphone             5
> ORGMBN2841ZDJDZD4HHEN28HB5YYP Headphone              1

Here is the link to the dataset

Rudra
  • 73
  • 4

2 Answers2

0

I know it's probably not a whole lot of help: but I found using Item Based Collaborative filtering circumvents this issue. I found an example here which returned the same error: https://rpubs.com/dhairavc/639597

I think it has something to do with the number of neighbours for UBCF.

If you change the line to:

learn <- Recommender(rrm2,method = "IBCF")

I imagine you will likely return a result. User-based isn't a friendly towards sparce matricies.

I hope this helps, I'll update you if I get any closer to a fix!

  • This surely does resolve the error, but gives me recommendations that are all over the place, and is not what I'm trying to do. But thanks! – Rudra Sep 07 '20 at 10:16
0

Change the Recommendation line with different methods

learn <- Recommender(rrm2,method = "IBCF") # Change with "UBCF","SVD","POPULAR"
Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62
sathish
  • 1
  • 1