guoguibing / librec

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

Save result for each fold (kcv or loocv) in version 3.0.0 #301

Open ChenglongMa opened 5 years ago

ChenglongMa commented 5 years ago

Hi all, Thanks for your all amazing job on librec.

I noticed that, compared with the version 2.0.0, version 3.0.0 has changed the behaviour in RecommenderJob#executeRecommenderJob().

More precisely, in ver 2.0.0, the result for each cv fold would be saved while in ver 3.0.0 only the last one is saved.

My questions are:

  1. I was wondering if this is a new feature? If so, could you refine the document/changelog to specify it?
  2. Would it be reasonable if I want to save each result:

in executeRecommenderJob()

int fold = 1; 
while (dataModel.hasNextFold()) {
    dataModel.nextFold();
    context.setDataModel(dataModel);
    generateSimilarity(context);
    recommender.train(context);
    executeEvaluator(recommender, context);
    // specify cv index
    conf.setInt("data.splitter.cv.index", fold++);
    // move from the outside of the while loop
    boolean isRanking = conf.getBoolean("rec.recommender.isranking");
    List<RecommendedItem> recommendedList;
    if (isRanking) {
        recommendedList = recommender.getRecommendedList(recommender.recommendRank());
    } else {
        recommendedList = recommender.getRecommendedList(recommender.recommendRating(context.getDataModel().getTestDataSet()));
    }
    recommendedList = filterResult(recommendedList);
    saveResult(recommendedList);
}