guoguibing / librec

LibRec: A Leading Java Library for Recommender Systems, see
https://www.librec.net/
Other
3.23k stars 1.03k forks source link

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

Open clark021125 opened 5 years ago

clark021125 commented 5 years ago

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.

SunYatong commented 5 years ago

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.

zjz2009000 commented 5 years ago

Good job!