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

Examples of org.apache.mahout.cf.taste.model.DataModel


      if (random.nextDouble() < evaluationPercentage) {
        processOneUser(trainingPercentage, trainingUsers, testUserPrefs, userID, dataModel);
      }
    }
   
    DataModel trainingModel = dataModelBuilder == null ? new GenericDataModel(trainingUsers)
        : dataModelBuilder.buildDataModel(trainingUsers);
   
    Recommender recommender = recommenderBuilder.buildRecommender(trainingModel);
   
    double result = getEvaluation(testUserPrefs, recommender);
View Full Code Here


public final class LoadEvaluator {
 
  private LoadEvaluator() { }
 
  public static void runLoad(Recommender recommender) throws TasteException {
    DataModel dataModel = recommender.getDataModel();
    int numUsers = dataModel.getNumUsers();
    double sampleRate = 1000.0 / numUsers;
    LongPrimitiveIterator userSampler = SamplingLongPrimitiveIterator.maybeWrapIterator(dataModel
        .getUserIDs(), sampleRate);
    recommender.recommend(userSampler.next(), 10); // Warm up
    Collection<Callable<Void>> callables = new ArrayList<Callable<Void>>();
    while (userSampler.hasNext()) {
      callables.add(new LoadCallable(recommender, userSampler.next()));
View Full Code Here

  }
 
  @Override
  public long[] getUserNeighborhood(long userID) throws TasteException {
   
    DataModel dataModel = getDataModel();
    UserSimilarity userSimilarityImpl = getUserSimilarity();
   
    TopItems.Estimator<Long> estimator = new Estimator(userSimilarityImpl, userID, minSimilarity);
   
    LongPrimitiveIterator userIDs = SamplingLongPrimitiveIterator.maybeWrapIterator(dataModel.getUserIDs(),
      getSamplingRate());
   
    return TopItems.getTopUsers(n, userIDs, null, estimator);
  }
View Full Code Here

  }
 
  @Override
  public long[] getUserNeighborhood(long userID) throws TasteException {
   
    DataModel dataModel = getDataModel();
    FastIDSet neighborhood = new FastIDSet();
    LongPrimitiveIterator usersIterable = SamplingLongPrimitiveIterator.maybeWrapIterator(dataModel
        .getUserIDs(), getSamplingRate());
    UserSimilarity userSimilarityImpl = getUserSimilarity();
   
    while (usersIterable.hasNext()) {
      long otherUserID = usersIterable.next();
View Full Code Here

          while (it2.hasNext()) {
            processOtherUser(userID, relevantItemIDs, trainingUsers, it2
                .nextLong(), dataModel);
          }
         
          DataModel trainingModel = dataModelBuilder == null ? new GenericDataModel(trainingUsers)
              : dataModelBuilder.buildDataModel(trainingUsers);
          Recommender recommender = recommenderBuilder.buildRecommender(trainingModel);
         
          try {
            trainingModel.getPreferencesFromUser(userID);
          } catch (NoSuchUserException nsee) {
            continue; // Oops we excluded all prefs for the user -- just move on
          }
         
          int intersectionSize = 0;
View Full Code Here

import org.apache.mahout.cf.taste.recommender.Recommender;

public final class RMSRecommenderEvaluatorTest extends TasteTestCase {

  public void testEvaluate() throws Exception {
    DataModel model = getDataModel();
    RecommenderBuilder builder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
View Full Code Here

import org.apache.mahout.cf.taste.recommender.Recommender;

public final class AverageAbsoluteDifferenceRecommenderEvaluatorTest extends TasteTestCase {

  public void testEvaluate() throws Exception {
    DataModel model = getDataModel();
    RecommenderBuilder builder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
View Full Code Here

/** <p>Tests {@link AveragingPreferenceInferrer}.</p> */
public final class AveragingPreferenceInferrerTest extends TasteTestCase {

  public void testInferrer() throws TasteException {
    DataModel model = getDataModel(new long[] {1}, new Double[][] {{3.0,-2.0,5.0}});
    PreferenceInferrer inferrer = new AveragingPreferenceInferrer(model);
    double inferred = inferrer.inferPreference(1, 3);
    assertEquals(2.0, inferred);
  }
View Full Code Here

import org.apache.mahout.cf.taste.recommender.Recommender;

public final class GenericRecommenderIRStatsEvaluatorImplTest extends TasteTestCase {

  public void testEvaluate() throws Exception {
    DataModel model = getDataModel();
    RecommenderBuilder builder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
        return new SlopeOneRecommender(dataModel);
      }
View Full Code Here

/** <p>Tests {@link TanimotoCoefficientSimilarity}.</p> */
public final class TanimotoCoefficientSimilarityTest extends SimilarityTestCase {

  public void testNoCorrelation() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2},
            new Double[][] {
                    {null, 2.0, 3.0},
                    {1.0},
            });
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.model.DataModel

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.