guoguibing / librec

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

Error message "the return value of "net.librec.recommender.RecommenderContext.getSimilarity()" is null" on itemknn #347

Closed samiravaez closed 2 years ago

samiravaez commented 2 years ago

I can run almost all the algorithms without any errors, but this does not apply to algorithms "itemknn" and "userknn". For example, for the algorithm "itemknn", I encounter the following error message in both versions 2 and 3:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "net.librec.similarity.RecommenderSimilarity.getSimilarityMatrix()" because the return value of "net.librec.recommender.RecommenderContext.getSimilarity()" is null
        at net.librec.recommender.cf.ItemKNNRecommender.setup(ItemKNNRecommender.java:55)
        at net.librec.recommender.AbstractRecommender.recommend(AbstractRecommender.java:219)
        at net.librec.job.RecommenderJob.executeRecommenderJob(RecommenderJob.java:144)
        at net.librec.job.RecommenderJob.runJob(RecommenderJob.java:122)
        at net.librec.tool.driver.RecDriver.run(RecDriver.java:84)
        at net.librec.tool.driver.RecDriver.main(RecDriver.java:111)

Do these two algorithms require special different settings or anything else? Can somebody help please?

rburke2233 commented 2 years ago

You might not have specified rec.similarity.class in your properties file.

samiravaez commented 2 years ago

My problem is solved. I thought the properties file would be called automatically when the algorithms were called, , and I did not specify its path in the command. Thank you