Package org.apache.mahout.cf.taste.similarity

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity


                    {0.2, 0.3, 0.3},
                    {0.4, 0.3, 0.5},
                    {0.7, 0.3, 0.8, 0.9},
            });

    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    assertEquals(0.9f, recommender.estimatePreference(3, 3));
  }
View Full Code Here


                    {0.4, 0.3, 0.5},
                    {0.7, 0.3, 0.8},
            });


    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
View Full Code Here

public final class BookCrossingBooleanRecommender implements Recommender {

  private final Recommender recommender;

  public BookCrossingBooleanRecommender(DataModel bcModel) throws TasteException {
    UserSimilarity similarity = new CachingUserSimilarity(new LogLikelihoodSimilarity(bcModel), bcModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(10, Double.NEGATIVE_INFINITY, similarity, bcModel, 1.0);
    recommender = new GenericBooleanPrefUserBasedRecommender(bcModel, neighborhood, similarity);
  }
View Full Code Here

public final class BookCrossingRecommender implements Recommender {

  private final Recommender recommender;

  public BookCrossingRecommender(DataModel bcModel) throws TasteException {
    UserSimilarity similarity = new CachingUserSimilarity(new EuclideanDistanceSimilarity(bcModel), bcModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(10, 0.2, similarity, bcModel, 0.2);
    recommender = new GenericUserBasedRecommender(bcModel, neighborhood, similarity);
  }
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());
View Full Code Here

   
    DataModel dataModel = getDataModel();
    FastIDSet neighborhood = new FastIDSet();
    LongPrimitiveIterator usersIterable = SamplingLongPrimitiveIterator.maybeWrapIterator(dataModel
        .getUserIDs(), getSamplingRate());
    UserSimilarity userSimilarityImpl = getUserSimilarity();
   
    while (usersIterable.hasNext()) {
      long otherUserID = usersIterable.next();
      if (userID != otherUserID) {
        double theSimilarity = userSimilarityImpl.userSimilarity(userID, otherUserID);
        if (!Double.isNaN(theSimilarity) && (theSimilarity >= threshold)) {
          neighborhood.add(otherUserID);
        }
      }
    }
View Full Code Here

            new Double[][] {
                    {0.1},
                    {0.2, 0.6},
                    {0.4, 0.9},
            });
    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(0, recommended.size());
View Full Code Here

                    {0.4, 0.4, 0.5, 0.9},
                    {0.1, 0.4, 0.5, 0.8, 0.9, 1.0},
                    {0.2, 0.3, 0.6, 0.7, 0.1, 0.2},
            });

    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    List<RecommendedItem> fewRecommended = recommender.recommend(1, 2);
    List<RecommendedItem> moreRecommended = recommender.recommend(1, 4);
    for (int i = 0; i < fewRecommended.size(); i++) {
View Full Code Here

                    {0.1, 0.2},
                    {0.2, 0.3, 0.3, 0.6},
                    {0.4, 0.4, 0.5, 0.9},
            });

    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    List<RecommendedItem> originalRecommended = recommender.recommend(1, 2);
    List<RecommendedItem> rescoredRecommended =
        recommender.recommend(1, 2, new ReversingRescorer<Long>());
View Full Code Here

                    {0.2, 0.3, 0.3},
                    {0.4, 0.3, 0.5},
                    {0.7, 0.3, 0.8, 0.9},
            });

    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    assertEquals(0.9f, recommender.estimatePreference(3, 3), EPSILON);
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.similarity.UserSimilarity

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.