public void usePredictedRatingsForContent(Method m, int userId) { // Store the original ratings in the map. Rating rec; content.setFixedUserId(userId); content.restart(); while ((rec = (Rating) content.next()) != null) { int objectId = rec.getObjectId(); double rating = rec.getRating(); if (!usersRatings.containsKey(userId)) usersRatings.put(userId, new HashMap<Integer, Double>()); usersRatings.get(userId).put(objectId, rating); } // Use the ratings from the behaviour method content.restart(); while ((rec = (Rating) content.next()) != null) { Double r = (Double) m.classifyRecord(rec); if (r != null) rec.setRating(r); } }
@Override public void setFixedUserId(Integer userId) { if (useBehaviour) behaviour.setFixedUserId(userId); else content.setFixedUserId(userId); }