private float doEstimatePreference(long userID, long itemID) {
   buildAveragesLock.readLock().lock();
   try {
     RunningAverage itemAverage = itemAverages.get(itemID);
     if (itemAverage == null) {
       return Float.NaN;
     }
     RunningAverage userAverage = userAverages.get(userID);
     if (userAverage == null) {
       return Float.NaN;
     }
     double userDiff = userAverage.getAverage() - overallAveragePrefValue.getAverage();
     return (float) (itemAverage.getAverage() + userDiff);
   } finally {
     buildAveragesLock.readLock().unlock();
   }
 }
Ejemplo n.º 2
0
  @Test
  public void testEvaluate() throws Exception {
    DataModel model = getDataModel();
    Recommender recommender1 = new SlopeOneRecommender(model);
    Recommender recommender2 = new ItemAverageRecommender(model);
    RecommenderEvaluator evaluator = new PreferenceBasedRecommenderEvaluator();

    RunningAverage tracker = new FullRunningAverage();
    evaluator.evaluate(recommender1, recommender2, 100, tracker, Formula.MEANRANK);
    double eval = tracker.getAverage();
    assertEquals(0.185294508934021, eval, EPSILON);
  }