Examples of itemSimilarity()


Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

                    {1.0, 2.0},
                    {2.0, 5.0},
                    {3.0, 6.0},
            });
    ItemSimilarity itemSimilarity = new PearsonCorrelationSimilarity(dataModel, Weighting.WEIGHTED);
    double correlation = itemSimilarity.itemSimilarity(0, 1);
    assertCorrelationEquals(0.9901922307076306, correlation);
  }

  public void testRefresh() throws Exception {
    // Make sure this doesn't throw an exception
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

                    {1.0, 2.0},
                    {2.0, 5.0},
                    {3.0, 6.0},
            });
    ItemSimilarity itemSimilarity = new EuclideanDistanceSimilarity(dataModel, Weighting.WEIGHTED);
    double correlation = itemSimilarity.itemSimilarity(0, 1);
    assertCorrelationEquals(0.8974062142054332, correlation);
  }

  public void testRefresh() throws TasteException {
    // Make sure this doesn't throw an exception
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

                    {2.0, 5.0},
                    {3.0, 6.0},
            });
    ItemSimilarity otherSimilarity = new PearsonCorrelationSimilarity(dataModel);
    ItemSimilarity itemSimilarity = new GenericItemSimilarity(otherSimilarity, dataModel);
    assertCorrelationEquals(1.0, itemSimilarity.itemSimilarity(0, 0));
    assertCorrelationEquals(0.960768922830523, itemSimilarity.itemSimilarity(0, 1));
  }

}
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

                    {3.0, 6.0},
            });
    ItemSimilarity otherSimilarity = new PearsonCorrelationSimilarity(dataModel);
    ItemSimilarity itemSimilarity = new GenericItemSimilarity(otherSimilarity, dataModel);
    assertCorrelationEquals(1.0, itemSimilarity.itemSimilarity(0, 0));
    assertCorrelationEquals(0.960768922830523, itemSimilarity.itemSimilarity(0, 1));
  }

}
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

  @Test
  public void testLoadFromFile() throws Exception {
    ItemSimilarity similarity = new FileItemSimilarity(testFile);

    assertEquals(0.125, similarity.itemSimilarity(1L, 5L), EPSILON);
    assertEquals(0.125, similarity.itemSimilarity(5L, 1L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(1L, 7L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(7L, 1L), EPSILON);

    assertTrue(Double.isNaN(similarity.itemSimilarity(7L, 8L)));
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

                    {1.0, 2.0},
                    {2.0, 5.0},
                    {3.0, 6.0},
            });
    ItemSimilarity itemSimilarity = new EuclideanDistanceSimilarity(dataModel, Weighting.WEIGHTED);
    double correlation = itemSimilarity.itemSimilarity(0, 1);
    assertCorrelationEquals(0.889954122647528, correlation);
  }

  @Test
  public void testRefresh() throws TasteException {
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

  @Test
  public void testLoadFromFile() throws Exception {
    ItemSimilarity similarity = new FileItemSimilarity(testFile);

    assertEquals(0.125, similarity.itemSimilarity(1L, 5L), EPSILON);
    assertEquals(0.125, similarity.itemSimilarity(5L, 1L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(1L, 7L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(7L, 1L), EPSILON);

    assertTrue(Double.isNaN(similarity.itemSimilarity(7L, 8L)));
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

  public void testLoadFromFile() throws Exception {
    ItemSimilarity similarity = new FileItemSimilarity(testFile);

    assertEquals(0.125, similarity.itemSimilarity(1L, 5L), EPSILON);
    assertEquals(0.125, similarity.itemSimilarity(5L, 1L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(1L, 7L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(7L, 1L), EPSILON);

    assertTrue(Double.isNaN(similarity.itemSimilarity(7L, 8L)));

    double[] valuesForOne = similarity.itemSimilarities(1L, new long[] { 5L, 7L });
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

    ItemSimilarity similarity = new FileItemSimilarity(testFile);

    assertEquals(0.125, similarity.itemSimilarity(1L, 5L), EPSILON);
    assertEquals(0.125, similarity.itemSimilarity(5L, 1L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(1L, 7L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(7L, 1L), EPSILON);

    assertTrue(Double.isNaN(similarity.itemSimilarity(7L, 8L)));

    double[] valuesForOne = similarity.itemSimilarities(1L, new long[] { 5L, 7L });
    assertNotNull(valuesForOne);
View Full Code Here

Examples of org.apache.mahout.cf.taste.similarity.ItemSimilarity.itemSimilarity()

    assertEquals(0.125, similarity.itemSimilarity(1L, 5L), EPSILON);
    assertEquals(0.125, similarity.itemSimilarity(5L, 1L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(1L, 7L), EPSILON);
    assertEquals(0.5, similarity.itemSimilarity(7L, 1L), EPSILON);

    assertTrue(Double.isNaN(similarity.itemSimilarity(7L, 8L)));

    double[] valuesForOne = similarity.itemSimilarities(1L, new long[] { 5L, 7L });
    assertNotNull(valuesForOne);
    assertEquals(2, valuesForOne.length);
    assertEquals(0.125, valuesForOne[0], EPSILON);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.