@Override
public EvaluationResult evaluate(MyrrixRecommender recommender,
RescorerProvider provider, // ignored
Multimap<Long,RecommendedItem> testData) throws TasteException {
DoubleWeightedMean score = new DoubleWeightedMean();
int count = 0;
for (Map.Entry<Long,RecommendedItem> entry : testData.entries()) {
long userID = entry.getKey();
RecommendedItem itemPref = entry.getValue();
try {
float estimate = recommender.estimatePreference(userID, itemPref.getItemID());
Preconditions.checkState(LangUtils.isFinite(estimate));
score.increment(1.0 - estimate, itemPref.getValue());
} catch (NoSuchItemException nsie) {
// continue
} catch (NoSuchUserException nsue) {
// continue
}
if (++count % 100000 == 0) {
log.info("Score: {}", score);
}
}
log.info("Score: {}", score);
return new EvaluationResultImpl(score.getResult());
}