librec icon indicating copy to clipboard operation
librec copied to clipboard

Suspicious bug within AbstractRecommender.java may lead to print incorrect results

Open clark021125 opened this issue 6 years ago • 2 comments

Hi,

I am new to LibRec. When playing around with the system I noticed that the recommend items it gives in output files are always identical regardless which ranking algorithm I used. So, I read through the source code and spotted these codes below which may not make sense.

https://github.com/guoguibing/librec/blob/63f8a733cc10127abcfd35dc91e16daf7970302a/core/src/main/java/net/librec/recommender/AbstractRecommender.java#L225

The method being called within parenthesis seems to be getKey() rather than getKeyIdx(), since keyIdx only depicts the index of key in the subclass below.

https://github.com/guoguibing/librec/blob/63f8a733cc10127abcfd35dc91e16daf7970302a/core/src/main/java/net/librec/recommender/item/RecommendedList.java#L285-L334

This would cause mismatch when interpreting a key to a real itemId and finally the itemIds in results files are always the same. However, LibRec is a complex system and I am still not sure if I am lending a hand.

clark021125 avatar Oct 24 '18 10:10 clark021125

Hi, thanks for your feedback. You are right, the previous code got the index of the iterator. It should be getKey() rather than getKeyIdx().

I just fixed the bug, please update your code and check my modification.

SunYatong avatar Oct 25 '18 14:10 SunYatong

Good job!

zjz2009000 avatar Dec 05 '18 06:12 zjz2009000