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

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


    double correlation = new EuclideanDistanceSimilarity(dataModel).userSimilarity(user1, user2);
    assertTrue(Double.isNaN(correlation));
  }

  public void testNoCorrelation3() throws Exception {
    User user1 = getUser("test1", 90.0, 80.0, 70.0);
    User user2 = getUser("test2", 70.0, 80.0, 90.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new EuclideanDistanceSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.3606507916004517, correlation);
  }
View Full Code Here


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

  public void testInferrer() throws TasteException {
    User user1 = getUser("test1", 3.0, -2.0, 5.0);
    Item item = new GenericItem<String>("3");
    DataModel model = new GenericDataModel(Collections.singletonList(user1));
    PreferenceInferrer inferrer = new AveragingPreferenceInferrer(model);
    double inferred = inferrer.inferPreference(user1, item);
    assertEquals(2.0, inferred);
View Full Code Here

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

  public void testNoCorrelation1() throws Exception {
    User user1 = getUser("test1");
    User user2 = getUser("test2");
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertTrue(Double.isNaN(correlation));
  }
View Full Code Here

    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertTrue(Double.isNaN(correlation));
  }

  public void testNoCorrelation2() throws Exception {
    User user1 = getUser("test1");
    User user2 = getUser("test2", 1.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.0, correlation);
  }
View Full Code Here

    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.0, correlation);
  }

  public void testNoCorrelation() throws Exception {
    User user1 = getUser("test1", null, 2.0, 3.0);
    User user2 = getUser("test2", 1.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.0, correlation);
  }
View Full Code Here

    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.0, correlation);
  }

  public void testFullCorrelation1() throws Exception {
    User user1 = getUser("test1", 1.0);
    User user2 = getUser("test2", 1.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(1.0, correlation);
  }
View Full Code Here

    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(1.0, correlation);
  }

  public void testFullCorrelation2() throws Exception {
    User user1 = getUser("test1", 1.0, 2.0, 3.0);
    User user2 = getUser("test2", 1.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.3333333333333333, correlation);
  }
View Full Code Here

    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.3333333333333333, correlation);
  }

  public void testCorrelation1() throws Exception {
    User user1 = getUser("test1", null, 2.0, 3.0);
    User user2 = getUser("test2", 1.0, 1.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertEquals(0.3333333333333333, correlation);
  }
View Full Code Here

    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertEquals(0.3333333333333333, correlation);
  }

  public void testCorrelation2() throws Exception {
    User user1 = getUser("test1", null, 2.0, 3.0, 1.0);
    User user2 = getUser("test2", 1.0, 1.0, null, 0.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new TanimotoCoefficientSimilarity(dataModel).userSimilarity(user1, user2);
    assertEquals(0.5, correlation);
  }
View Full Code Here

    users.add(getUser("test4", 0.7, 0.8, 0.9, 1.0));
    users.add(getUser("test5", 1.0, 1.0, 1.0, 1.0, 1.0));
    GenericDataModel dummy = new GenericDataModel(users);
    InverseUserFrequency iuf = new InverseUserFrequency(dummy, 10.0);

    User user = dummy.getUser("test5");
    for (int i = 0; i < 5; i++) {
      Preference pref = user.getPreferenceFor(String.valueOf(i));
      assertNotNull(pref);
      assertEquals(Math.log(5.0 / (double) (5 - i)) / Math.log(iuf.getLogBase()),
                   iuf.getTransformedValue(pref),
                   EPSILON);
    }
View Full Code Here

TOP

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

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.