Package org.apache.mahout.cf.taste.eval

Examples of org.apache.mahout.cf.taste.eval.RecommenderIRStatsEvaluator


  }

  public static void main(String[] args) throws Exception {
    DataModel model = new FileDataModel(new File("ratings.dat"));
    model = new GenericBooleanPrefDataModel(GenericBooleanPrefDataModel.toDataMap(model));
      RecommenderIRStatsEvaluator evaluator =
        new GenericRecommenderIRStatsEvaluator();
      RecommenderBuilder recommenderBuilder = new RecommenderBuilder() {
        @Override
        public Recommender buildRecommender(DataModel model) throws TasteException {
          UserSimilarity similarity = new TanimotoCoefficientSimilarity(model);
          UserNeighborhood neighborhood = new NearestNUserNeighborhood(2, similarity, model);
          return new GenericBooleanPrefUserBasedRecommender(model, neighborhood, similarity);
        }
      };
      IRStatistics stats = evaluator.evaluate(recommenderBuilder, null, model, null, 10, Double.NaN, 0.1);
      System.out.println(stats);
  }
View Full Code Here


    System.err.println("Please, specify name of file, or put file 'input.csv' into current directory!");
    System.exit(1);
  }
    DataModel model = new FileDataModel(modelFile);

    RecommenderIRStatsEvaluator evaluator =
      new GenericRecommenderIRStatsEvaluator();
    // Build the same recommender for testing that we did last time:
    RecommenderBuilder recommenderBuilder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel model) throws TasteException {
        UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
        UserNeighborhood neighborhood =
          new NearestNUserNeighborhood(2, similarity, model);
        return new GenericUserBasedRecommender(model, neighborhood, similarity);
      }
    };
    // Evaluate precision and recall "at 2":
    IRStatistics stats = evaluator.evaluate(recommenderBuilder,
                                            null, model, null, 2,
                                            GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD,
                                            1.0);
    System.out.println(stats.getPrecision());
    System.out.println(stats.getRecall());
View Full Code Here

  public static void main(String[] args) throws Exception {
    DataModel model = new GenericBooleanPrefDataModel(
        GenericBooleanPrefDataModel.toDataMap(
          new FileDataModel(new File("ua.base"))));

    RecommenderIRStatsEvaluator evaluator =
      new GenericRecommenderIRStatsEvaluator();
    RecommenderBuilder recommenderBuilder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel model) throws TasteException {
        UserSimilarity similarity = new LogLikelihoodSimilarity(model);
        UserNeighborhood neighborhood =
          new NearestNUserNeighborhood(10, similarity, model);
        return new GenericBooleanPrefUserBasedRecommender(model, neighborhood, similarity);
      }
    };
    DataModelBuilder modelBuilder = new DataModelBuilder() {
      @Override
      public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) {
        return new GenericBooleanPrefDataModel(
          GenericBooleanPrefDataModel.toDataMap(trainingData));
      }
    };
    IRStatistics stats = evaluator.evaluate(
        recommenderBuilder, modelBuilder, model, null, 10,
        GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD,
        1.0);
    System.out.println(stats.getPrecision());
    System.out.println(stats.getRecall());
View Full Code Here

      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
    };
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    IRStatistics stats = evaluator.evaluate(builder, null, model, null, 1, 0.2, 1.0);
    assertNotNull(stats);
    assertEquals(0.75, stats.getPrecision(), EPSILON);
    assertEquals(0.75, stats.getRecall(), EPSILON);
    assertEquals(0.75, stats.getF1Measure(), EPSILON);
  }
View Full Code Here

  private BookCrossingBooleanRecommenderEvaluatorRunner() {
    // do nothing
  }

  public static void main(String... args) throws IOException, TasteException, OptionException {
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    DataModel model;
    File ratingsFile = TasteOptionParser.getRatings(args);
    if (ratingsFile != null) {
      model = new BookCrossingDataModel(ratingsFile, true);
    } else {
      model = new BookCrossingDataModel(true);
    }

    IRStatistics evaluation = evaluator.evaluate(
        new BookCrossingBooleanRecommenderBuilder(),
        new BookCrossingDataModelBuilder(),
        model,
        null,
        3,
View Full Code Here

      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
    };
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    IRStatistics stats = evaluator.evaluate(builder, null, model, null, 1, 0.2, 1.0);
    assertNotNull(stats);
    assertEquals(0.75, stats.getPrecision(), EPSILON);
    assertEquals(0.75, stats.getRecall(), EPSILON);
    assertEquals(0.75, stats.getF1Measure(), EPSILON);
  }
View Full Code Here

      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
    };
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    IRStatistics stats = evaluator.evaluate(builder, model, null, 5, 0.2, 1.0);
    assertNotNull(stats);
    assertEquals(0.5, stats.getPrecision(), EPSILON);
    assertEquals(1.0, stats.getRecall(), EPSILON);
    assertEquals(0.6666666666666666, stats.getF1Measure(), EPSILON);
  }
View Full Code Here

  private BookCrossingBooleanRecommenderEvaluatorRunner() {
    // do nothing
  }

  public static void main(String... args) throws IOException, TasteException, OptionException {
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    File ratingsFile = TasteOptionParser.getRatings(args);
    DataModel model =
        ratingsFile == null ? new BookCrossingDataModel(true) : new BookCrossingDataModel(ratingsFile, true);

    IRStatistics evaluation = evaluator.evaluate(
        new BookCrossingBooleanRecommenderBuilder(),
        new BookCrossingDataModelBuilder(),
        model,
        null,
        3,
View Full Code Here

      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
    };
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    IRStatistics stats = evaluator.evaluate(builder, null, model, null, 1, 0.2, 1.0);
    assertNotNull(stats);
    assertEquals(0.75, stats.getPrecision(), EPSILON);
    assertEquals(0.75, stats.getRecall(), EPSILON);
    assertEquals(0.75, stats.getF1Measure(), EPSILON);
    assertEquals(0.75, stats.getFNMeasure(2.0), EPSILON);
View Full Code Here

      @Override
      public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) {
        return new GenericBooleanPrefDataModel(GenericBooleanPrefDataModel.toDataMap(trainingData));
      }
    };
    RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
    IRStatistics stats = evaluator.evaluate(
        builder, dataModelBuilder, model, null, 1, GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1.0);

    assertNotNull(stats);
    assertEquals(0.666666666, stats.getPrecision(), EPSILON);
    assertEquals(0.666666666, stats.getRecall(), EPSILON);
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.eval.RecommenderIRStatsEvaluator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.