protected float doEstimatePreference(long theUserID, long[] theNeighborhood, long itemID) throws TasteException {
if (theNeighborhood.length == 0) {
return Float.NaN;
}
DataModel dataModel = getDataModel();
UserSimilarity similarity = getSimilarity();
float totalSimilarity = 0.0f;
boolean foundAPref = false;
for (long userID : theNeighborhood) {
// See GenericItemBasedRecommender.doEstimatePreference() too
if (userID != theUserID && dataModel.getPreferenceValue(userID, itemID) != null) {
foundAPref = true;
totalSimilarity += (float) similarity.userSimilarity(theUserID, userID);
}
}
return foundAPref ? totalSimilarity : Float.NaN;
}