mhahsler / recommenderlab

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

UBCF returns 1 as rating for predicted values with the weighted flag on binaryRatingMatrix #41

Closed bhawwash closed 4 years ago

bhawwash commented 4 years ago

Hello

When building a recommendation model using a binaryRatingMatrix, the predicted ratings are always 1 when "weighted" instead of the weighted average.

This behavior is only in 0.2-6 (it worked fine in 0.2-4)

library(recommenderlab)
data("MovieLense")
MovieLense100 <- MovieLense[rowCounts(MovieLense) >100,]
MovieLense100 = binarize(MovieLense100,minRating=1)

train <- MovieLense100[1:50]
rec <- Recommender(train, method = "UBCF", list(weighted=TRUE))

pre <- predict(rec, MovieLense100[101:102], n = 10)
pre@ratings
mhahsler commented 4 years ago

Hi, thank you for the bug report. I have fixed the normalizing of the weights in the development version on GitHub. Please install this version and check if it now behaves as expected.

bhawwash commented 4 years ago

Yes, that did the trick. Thanks