mhahsler / recommenderlab

recommenderlab - Lab for Developing and Testing Recommender Algorithms - R package
213 stars 61 forks source link

User-based Collaborative Filtering fails in nearest neighbor assignment #43

Closed jluningh closed 3 years ago

jluningh commented 4 years ago

Hi there,

I teach a class that involves a few lessons using RecommenderLab, and my students and I are encountering an error when using predict with user-based CF: Error in neighbors[, x] : incorrect number of dimensions. I thought it might be due to sparseness of the data, so I encouraged my students to try out different options for nearest neighbors. However, the error continued.

I re-ran code that as of November 2019 executed UBCF without issue and it now fails. Is this error a result of a new update?

Here is my data: BDS-W12-fullrecommender-DataSet.txt , and here is my code that produces the error:

dat <- read.csv("BDS-W12-fullrecommender-DataSet.csv", header=T)

dat <- as.data.frame(dat)
dat2 <- dat %>%
  dplyr::select( userID,placeID,rating)

dat3<-as(dat2, "realRatingMatrix")

e2 <- evaluationScheme(dat3, method="split", train=.7, given=2) # small 'given' because some users have few ratings

r2 <- HybridRecommender( Recommender(getData(e2, "train"), "IBCF"),  Recommender(getData(e2, "train"), "UBCF"))
r2

# prediction, "e2, known" signifies the 2 ratings in the test dataset.
p2 <- predict(r2, getData(e2, "known"), type="ratings")
mhahsler commented 3 years ago

I think this is addressed by the latest release. Please reopen if not.