public static void evaluate(
     RecommenderEvaluator re,
     RecommenderBuilder rb,
     DataModelBuilder mb,
     DataModel dm,
     double trainPt)
     throws TasteException {
   System.out.printf("Evaluater Score:%s\n", re.evaluate(rb, mb, dm, trainPt, 1.0));
 }
Example #2
0
  @Test
  public void testOne() throws TasteException {
    RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
    FastByIDMap<PreferenceArray> usersData = usersData();
    DataModel model = new GenericDataModel(usersData);

    double evaluation = evaluator.evaluate(new CrossingRecommenderBuilder(), null, model, 1, 0.5);
    log.info(String.valueOf(evaluation));
  }
  @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);
  }
Example #4
0
  /** 基本算法 */
  public static void demo1(DataModel m) throws Exception {
    System.out.println("==============用户,打分,平均差值(0)==============");

    // 推荐结果
    UserSimilarity s = MySimilarity.getPearsonCorrelation(m);
    UserNeighborhood n = MyNeighborhood.getNearestN(m, s, 2);
    RecommenderBuilder rb = MyRecommender.userBuilder(s, n);
    MyRecommender.showItems(rb.buildRecommender(m).recommend(26, 1));

    RecommenderEvaluator e = new AverageAbsoluteDifferenceRecommenderEvaluator();
    double score = e.evaluate(rb, null, m, 0.9, 1.0); // testing data, all
    // data
    System.out.println("算法得分: " + score);
    System.out.println();
  }
Example #5
0
  public static void demo2(DataModel m) throws Exception {
    System.out.println("==============用户,打分,均方根(0)==============");

    // 推荐结果
    UserSimilarity s = MySimilarity.getPearsonCorrelation(m);
    UserNeighborhood n = MyNeighborhood.getNearestN(m, s, 2);
    RecommenderBuilder rb = MyRecommender.userBuilder(s, n);
    MyRecommender.showItems(rb.buildRecommender(m).recommend(26, 1));

    // RandomUtils.useTestSeed();
    RecommenderEvaluator e = new RMSRecommenderEvaluator();
    double score = e.evaluate(rb, null, m, 0.7, 0.3); // testing data, all
    // data
    System.out.println("算法得分: " + score);

    System.out.println();
  }
Example #6
0
  public static void demo3(DataModel m) throws Exception {
    System.out.println("==============用户,无打分,平均差值(0)==============");

    // 推荐结果
    UserSimilarity s = new LogLikelihoodSimilarity(m);
    UserNeighborhood n = MyNeighborhood.getNearestN(m, s, 2);
    RecommenderBuilder rb = MyRecommender.userBuilder(s, n);
    MyRecommender.showItems(rb.buildRecommender(m).recommend(1, 1));

    // 算法得分
    // RandomUtils.useTestSeed();
    RecommenderEvaluator e = new AverageAbsoluteDifferenceRecommenderEvaluator();
    DataModelBuilder db = MyDataModel.createNoPrefDataModelBuilder();
    double score = e.evaluate(rb, db, m, 0.7, 1.0); // testing data, all data
    System.out.println("算法得分: " + score);

    System.out.println();
  }