Examples of userSimilarity()


Examples of org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity.userSimilarity()

     
      PearsonCorrelationSimilarity pearsonSimilarity = new PearsonCorrelationSimilarity(model);
     
      // Java: Similarity between Wolf and Bear: 0.8196561646738477
      // R: corr(c(8,3,1),c(8,7,2)): 0.8196562
      System.out.println("Similarity between Wolf and Bear: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Bear")));
      // Similarity between Wolf and Rabbit: -0.6465846072812313
      // R: cor(c(8,3,1),c(2,1,10)): -0.6465846
      System.out.println("Similarity between Wolf and Rabbit: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Rabbit")));
      // Similarity between Wolf and Pinguin: -0.24019223070763077
      // R: cor(c(8,3,1),c(2,10,2)): -0.2401922
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity.userSimilarity()

      // Java: Similarity between Wolf and Bear: 0.8196561646738477
      // R: corr(c(8,3,1),c(8,7,2)): 0.8196562
      System.out.println("Similarity between Wolf and Bear: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Bear")));
      // Similarity between Wolf and Rabbit: -0.6465846072812313
      // R: cor(c(8,3,1),c(2,1,10)): -0.6465846
      System.out.println("Similarity between Wolf and Rabbit: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Rabbit")));
      // Similarity between Wolf and Pinguin: -0.24019223070763077
      // R: cor(c(8,3,1),c(2,10,2)): -0.2401922
      System.out.println("Similarity between Wolf and Pinguin: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Pinguin")));
     
      GenericUserBasedRecommender recommender = new GenericUserBasedRecommender(model, new NearestNUserNeighborhood(3, pearsonSimilarity, model), pearsonSimilarity);
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity.userSimilarity()

      // Similarity between Wolf and Rabbit: -0.6465846072812313
      // R: cor(c(8,3,1),c(2,1,10)): -0.6465846
      System.out.println("Similarity between Wolf and Rabbit: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Rabbit")));
      // Similarity between Wolf and Pinguin: -0.24019223070763077
      // R: cor(c(8,3,1),c(2,10,2)): -0.2401922
      System.out.println("Similarity between Wolf and Pinguin: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Pinguin")));
     
      GenericUserBasedRecommender recommender = new GenericUserBasedRecommender(model, new NearestNUserNeighborhood(3, pearsonSimilarity, model), pearsonSimilarity);
      for(RecommendedItem r : recommender.recommend(id2thing.toLongID("Wolf"), 3)) {
        // Pork:
        // (0.8196561646738477 * 8 + (-0.6465846072812313) * 1) / (0.8196561646738477 + (-0.6465846072812313)) = 34,15157 ~ 10
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

    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

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

    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

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

    boolean foundAPref = false;
    for (long userID : theNeighborhood) {
      // See GenericItemBasedRecommender.doEstimatePreference() too
      if ((userID != theUserID) && (dataModel.getPreferenceValue(userID, itemID) != null)) {
        foundAPref = true;
        totalSimilarity += similarity.userSimilarity(theUserID, userID);
      }
    }
    return foundAPref ? totalSimilarity : Float.NaN;
  }
 
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

    UserSimilarity userSimilarityImpl = getUserSimilarity();

    while (users.hasNext()) {
      User user = users.next();
      if (sampleForUser() && !userID.equals(user.getID())) {
        double theSimilarity = userSimilarityImpl.userSimilarity(theUser, user);
        if (!Double.isNaN(theSimilarity) && theSimilarity >= threshold) {
          neighborhood.add(user);
        }
      }
    }
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

      @Override
      public void refresh(Collection<Refreshable> alreadyRefreshed) {
      }
    });

    assertEquals(-0.435285750066007, similarity.userSimilarity(1L, 2L), EPSILON);
  }

}
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

    boolean foundAPref = false;
    for (long userID : theNeighborhood) {
      // See GenericItemBasedRecommender.doEstimatePreference() too
      if (userID != theUserID && dataModel.getPreferenceValue(userID, itemID) != null) {
        foundAPref = true;
        totalSimilarity += (float) similarity.userSimilarity(theUserID, userID);
      }
    }
    return foundAPref ? totalSimilarity : Float.NaN;
  }
 
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.UserSimilarity.userSimilarity()

    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
TOP
Copyright © 2018 www.massapi.com. 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.