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

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


* <p>Tests {@link ZScore}.</p>
*/
public final class ZScoreTest extends TransformTestCase {

  public void testOnePref() throws Exception {
    User user = getUser("test", 1.0);
    PreferenceTransform zScore = new ZScore();
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("0")), EPSILON);
  }
View Full Code Here


    PreferenceTransform zScore = new ZScore();
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("0")), EPSILON);
  }

  public void testAllSame() throws Exception {
    User user = getUser("test", 1.0, 1.0, 1.0);
    PreferenceTransform zScore = new ZScore();
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("0")), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("1")), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("2")), EPSILON);
  }
View Full Code Here

    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("1")), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("2")), EPSILON);
  }

  public void testStdev() throws Exception {
    User user = getUser("test", -1.0, -2.0);
    PreferenceTransform zScore = new ZScore();
    assertEquals(0.707107, zScore.getTransformedValue(user.getPreferenceFor("0")), EPSILON);
    assertEquals(-0.707107, zScore.getTransformedValue(user.getPreferenceFor("1")), EPSILON);
  }
View Full Code Here

    assertEquals(0.707107, zScore.getTransformedValue(user.getPreferenceFor("0")), EPSILON);
    assertEquals(-0.707107, zScore.getTransformedValue(user.getPreferenceFor("1")), EPSILON);
  }

  public void testExample() throws Exception {
    User user = getUser("test", 5.0, 7.0, 9.0);
    PreferenceTransform zScore = new ZScore();
    assertEquals(-1.0, zScore.getTransformedValue(user.getPreferenceFor("0")), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(user.getPreferenceFor("1")), EPSILON);
    assertEquals(1.0, zScore.getTransformedValue(user.getPreferenceFor("2")), EPSILON);
  }
View Full Code Here

    double correlation = new EuclideanDistanceSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.3606507916004517, correlation);
  }

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

    double correlation = new EuclideanDistanceSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.5896248568217328, correlation);
  }

  public void testSimpleWeighted() throws Exception {
    User user1 = getUser("test1", 1.0, 2.0, 3.0);
    User user2 = getUser("test2", 2.0, 5.0, 6.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation = new EuclideanDistanceSimilarity(dataModel, Weighting.WEIGHTED).userSimilarity(user1, user2);
    assertCorrelationEquals(0.8974062142054332, correlation);
  }
View Full Code Here

    double correlation = new EuclideanDistanceSimilarity(dataModel, Weighting.WEIGHTED).userSimilarity(user1, user2);
    assertCorrelationEquals(0.8974062142054332, correlation);
  }

  public void testFullItemCorrelation1() throws Exception {
    User user1 = getUser("test1", 3.0, 3.0);
    User user2 = getUser("test2", -2.0, -2.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation =
            new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    assertCorrelationEquals(1.0, correlation);
  }
View Full Code Here

            new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    assertCorrelationEquals(1.0, correlation);
  }

  public void testFullItemCorrelation2() throws Exception {
    User user1 = getUser("test1", 3.0, 3.0);
    User user2 = getUser("test2", 3.0, 3.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation =
            new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    // Yeah, undefined in this case
    assertTrue(Double.isNaN(correlation));
View Full Code Here

    // Yeah, undefined in this case
    assertTrue(Double.isNaN(correlation));
  }

  public void testNoItemCorrelation1() throws Exception {
    User user1 = getUser("test1", 3.0, -3.0);
    User user2 = getUser("test2", -2.0, 2.0);
    DataModel dataModel = getDataModel(user1, user2);
    double correlation =
            new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    assertCorrelationEquals(0.424465381883345, correlation);
  }
View Full Code Here

            new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("1"), dataModel.getItem("2"));
    assertTrue(Double.isNaN(correlation));
  }

  public void testNoItemCorrelation3() throws Exception {
    User user1 = getUser("test1", 90.0, 70.0);
    User user2 = getUser("test2", 80.0, 80.0);
    User user3 = getUser("test3", 70.0, 90.0);
    DataModel dataModel = getDataModel(user1, user2, user3);
    double correlation =
            new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    assertCorrelationEquals(0.3606507916004517, correlation);
  }
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.