Package org.apache.mahout.cf.taste.impl.model

Examples of org.apache.mahout.cf.taste.impl.model.GenericBooleanPrefDataModel


  private LibimsetiIREvalRunner() {
  }

  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 {
View Full Code Here


  private IREvaluatorBooleanPrefIntro1() {
  }

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

    RecommenderEvaluator evaluator =
      new AverageAbsoluteDifferenceRecommenderEvaluator();
    RecommenderBuilder recommenderBuilder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel model) throws TasteException {
        UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
        UserNeighborhood neighborhood =
          new NearestNUserNeighborhood(10, similarity, model);
        return new GenericUserBasedRecommender(model, neighborhood, similarity);
      }
    };
    DataModelBuilder modelBuilder = new DataModelBuilder() {
      @Override
      public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) {
        return new GenericBooleanPrefDataModel(
          GenericBooleanPrefDataModel.toDataMap(trainingData));
      }
    };
    double score = evaluator.evaluate(
        recommenderBuilder, modelBuilder, model, 0.9, 1.0);
View Full Code Here

  private IREvaluatorBooleanPrefIntro2() {
  }

  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,
View Full Code Here

       
        for (File updateFile : findUpdateFiles()) {
          processFileWithoutID(new FileLineIterator(updateFile, false), data);
        }
       
        return new GenericBooleanPrefDataModel(data);
       
      } else {
       
        FastByIDMap<FastIDSet> rawData = ((GenericBooleanPrefDataModel) delegate).getRawUserData();
       
        for (File updateFile : findUpdateFiles()) {
          processFileWithoutID(new FileLineIterator(updateFile, false), rawData);
        }
       
        return new GenericBooleanPrefDataModel(rawData);
       
      }
     
    }
  }
View Full Code Here

        for (File updateFile : findUpdateFiles()) {
          processFileWithoutID(new FileLineIterator(updateFile, false), data, timestamps);
        }

        return new GenericBooleanPrefDataModel(data, timestamps);

      } else {

        FastByIDMap<FastIDSet> rawData = ((GenericBooleanPrefDataModel) delegate).getRawUserData();

        for (File updateFile : findUpdateFiles()) {
          processFileWithoutID(new FileLineIterator(updateFile, false), rawData, timestamps);
        }

        return new GenericBooleanPrefDataModel(rawData, timestamps);

      }

    }
  }
View Full Code Here

      // Load new in-memory representation,
      log.info("Loading new JDBC delegate data...");
      DataModel newDelegateInMemory =
          delegate.hasPreferenceValues()
          ? new GenericDataModel(delegate.exportWithPrefs())
          : new GenericBooleanPrefDataModel(delegate.exportWithIDsOnly());
      // and then swap to it.
      log.info("New data loaded.");
      delegateInMemory = newDelegateInMemory;
    } catch (TasteException te) {
      log.warn("Error while reloading JDBC delegate data", te);
View Full Code Here

        for (File updateFile : findUpdateFilesAfter(newLastModified)) {
          processFileWithoutID(new FileLineIterator(updateFile, false), data, timestamps);
        }

        return new GenericBooleanPrefDataModel(data, timestamps);

      } else {

        FastByIDMap<FastIDSet> rawData = ((GenericBooleanPrefDataModel) delegate).getRawUserData();

        for (File updateFile : findUpdateFilesAfter(Math.max(oldLastUpdateFileModifieid, newLastModified))) {
          processFileWithoutID(new FileLineIterator(updateFile, false), rawData, timestamps);
        }

        return new GenericBooleanPrefDataModel(rawData, timestamps);

      }

    }
  }
View Full Code Here

final class BookCrossingDataModelBuilder implements DataModelBuilder {

  @Override
  public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) {
    return new GenericBooleanPrefDataModel(GenericBooleanPrefDataModel.toDataMap(trainingData));
  }
View Full Code Here

      }
      if (!prefsSet.isEmpty()) {
        result.put(userIDs[i], prefsSet);
      }
    }
    return new GenericBooleanPrefDataModel(result);
  }
View Full Code Here

      }
    };
    DataModelBuilder dataModelBuilder = new DataModelBuilder() {
      @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);
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.model.GenericBooleanPrefDataModel

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.