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

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


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

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


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

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

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

  public void testFullCorrelation2() 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 PearsonCorrelationSimilarity(dataModel).userSimilarity(user1, user2);
    // Yeah, undefined in this case
    assertTrue(Double.isNaN(correlation));
  }
View Full Code Here

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

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

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

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

    double correlation = new PearsonCorrelationSimilarity(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 PearsonCorrelationSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(-1.0, correlation);
  }
View Full Code Here

    double correlation = new PearsonCorrelationSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(-1.0, 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 PearsonCorrelationSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.9607689228305227, correlation);
  }
View Full Code Here

    double correlation = new PearsonCorrelationSimilarity(dataModel).userSimilarity(user1, user2);
    assertCorrelationEquals(0.9607689228305227, 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 PearsonCorrelationSimilarity(dataModel, Weighting.WEIGHTED).userSimilarity(user1, user2);
    assertCorrelationEquals(0.9901922307076306, correlation);
  }
View Full Code Here

    double correlation = new PearsonCorrelationSimilarity(dataModel, Weighting.WEIGHTED).userSimilarity(user1, user2);
    assertCorrelationEquals(0.9901922307076306, 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 PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    assertCorrelationEquals(1.0, correlation);
  }
View Full Code Here

            new PearsonCorrelationSimilarity(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 PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
    // Yeah, undefined in this case
    assertTrue(Double.isNaN(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.