Recommender recommender)
throws TasteException {
RunningAverage average = new FullRunningAverage();
for (Map.Entry<User, Collection<Preference>> entry : testUserPrefs.entrySet()) {
for (Preference realPref : entry.getValue()) {
User testUser = entry.getKey();
try {
double estimatedPreference =
recommender.estimatePreference(testUser.getID(), realPref.getItem().getID());
if (!Double.isNaN(estimatedPreference)) {
average.addDatum(Math.abs(realPref.getValue() - estimatedPreference));
}
} catch (NoSuchUserException nsue) {
// It's possible that an item exists in the test data but not training data in which case
// NSEE will be thrown. Just ignore it and move on.
log.debug("User exists in test data but not training data: {}", testUser.getID(), nsue);
} catch (NoSuchItemException nsie) {
log.debug("Item exists in test data but not training data: {}", realPref.getItem().getID(), nsie);
}
}
}