Package org.apache.mahout.cf.taste.transforms

Examples of org.apache.mahout.cf.taste.transforms.PreferenceTransform


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

  public void testOnePref() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{1.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
  }
View Full Code Here


    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
  }

  public void testAllSame() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{1.0,1.0,1.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 1, 1.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 2, 1.0f)), EPSILON);
  }
View Full Code Here

    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 2, 1.0f)), EPSILON);
  }

  public void testStdev() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{-1.0,-2.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.707107, zScore.getTransformedValue(new GenericPreference(1, 0, -1.0f)), EPSILON);
    assertEquals(-0.707107, zScore.getTransformedValue(new GenericPreference(1, 1, -2.0f)), EPSILON);
  }
View Full Code Here

    assertEquals(-0.707107, zScore.getTransformedValue(new GenericPreference(1, 1, -2.0f)), EPSILON);
  }

  public void testExample() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{5.0, 7.0, 9.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(-1.0, zScore.getTransformedValue(new GenericPreference(1, 0, 5.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 1, 7.0f)), EPSILON);
    assertEquals(1.0, zScore.getTransformedValue(new GenericPreference(1, 2, 9.0f)), EPSILON);
  }
View Full Code Here

    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

*/
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

    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("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

public final class ZScoreTest extends TransformTestCase {

  @Test
  public void testOnePref() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{1.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
  }
View Full Code Here

  }

  @Test
  public void testAllSame() throws Exception {
    DataModel dataModel = getDataModel(new long[] {1}, new Double[][] {{1.0,1.0,1.0}});
    PreferenceTransform zScore = new ZScore(dataModel);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 0, 1.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 1, 1.0f)), EPSILON);
    assertEquals(0.0, zScore.getTransformedValue(new GenericPreference(1, 2, 1.0f)), EPSILON);
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.transforms.PreferenceTransform

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.