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

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


    double correlation = new PearsonCorrelationSimilarity(dataModel, Weighting.WEIGHTED).userSimilarity(1, 2);
    assertCorrelationEquals(0.9901922307076306, correlation);
  }

  public void testFullItemCorrelation1() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2},
            new Double[][] {
                    {3.0, 3.0},
                    {-2.0, -2.0},
            });
View Full Code Here


        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(0, 1);
    assertCorrelationEquals(1.0, correlation);
  }

  public void testFullItemCorrelation2() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2},
            new Double[][] {
                    {3.0, 3.0},
                    {3.0, 3.0},
            });
View Full Code Here

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

  public void testNoItemCorrelation1() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2},
            new Double[][] {
                    {3.0, -3.0},
                    {2.0, -2.0},
            });
View Full Code Here

        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(0, 1);
    assertCorrelationEquals(-1.0, correlation);
  }

  public void testNoItemCorrelation2() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2},
            new Double[][] {
                    {null, 1.0, null},
                    {null, null, 1.0},
            });
View Full Code Here

        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(1, 2);
    assertTrue(Double.isNaN(correlation));
  }

  public void testNoItemCorrelation3() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3},
            new Double[][] {
                    {90.0, 70.0},
                    {80.0, 80.0},
                    {70.0, 90.0},
View Full Code Here

        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(0, 1);
    assertCorrelationEquals(-1.0, correlation);
  }

  public void testSimpleItem() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3},
            new Double[][] {
                    {1.0, 2.0},
                    {2.0, 5.0},
                    {3.0, 6.0},
View Full Code Here

        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(0, 1);
    assertCorrelationEquals(0.9607689228305227, correlation);
  }

  public void testSimpleItemWeighted() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3},
            new Double[][] {
                    {1.0, 2.0},
                    {2.0, 5.0},
                    {3.0, 6.0},
View Full Code Here

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

  public void testIUF() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3, 4, 5},
            new Double[][] {
                    {0.1},
                    {0.2, 0.3},
                    {0.4, 0.5, 0.6},
                    {0.7, 0.8, 0.9, 1.0},
                    {1.0, 1.0, 1.0, 1.0, 1.0},
            });

    InverseUserFrequency iuf = new InverseUserFrequency(dataModel, 10.0);

    PreferenceArray user5Prefs = dataModel.getPreferencesFromUser(5);

    for (int i = 0; i < 5; i++) {
      Preference pref = user5Prefs.get(i);
      assertNotNull(pref);
      assertEquals(Math.log(5.0 / (double) (5 - i)) / Math.log(iuf.getLogBase()),
View Full Code Here

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

  public void testCorrelation() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2, 3, 4, 5},
            new Double[][] {
                    {1.0, 1.0},
                    {1.0, null, 1.0},
                    {null, null, 1.0, 1.0, 1.0},
View Full Code Here

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

  public void testFullCorrelation1() throws Exception {
    DataModel dataModel = getDataModel(
            new long[] {1, 2},
            new Double[][] {
                    {3.0, -2.0},
                    {3.0, -2.0},
            });
View Full Code Here

TOP

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

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.