Package org.apache.mahout.cf.taste.similarity

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.8210911630511055, correlation);
  }

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


                    {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));
  }

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

                    {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));
  }

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

                    {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));
  }

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

                    {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));
  }

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

    EasyMock.replay(dataSource, connection, statement, resultSet);

    ItemSimilarity similarity = new MySQLJDBCInMemoryItemSimilarity(dataSource);

    assertEquals(0.5, similarity.itemSimilarity(1L, 2L), EPSILON);
    assertEquals(0.4, similarity.itemSimilarity(1L, 3L), EPSILON);
    assertEquals(0.1, similarity.itemSimilarity(3L, 4L), EPSILON);
    assertTrue(Double.isNaN(similarity.itemSimilarity(1L, 4L)));

    EasyMock.verify(dataSource, connection, statement, resultSet);
View Full Code Here

    EasyMock.replay(dataSource, connection, statement, resultSet);

    ItemSimilarity similarity = new MySQLJDBCInMemoryItemSimilarity(dataSource);

    assertEquals(0.5, similarity.itemSimilarity(1L, 2L), EPSILON);
    assertEquals(0.4, similarity.itemSimilarity(1L, 3L), EPSILON);
    assertEquals(0.1, similarity.itemSimilarity(3L, 4L), EPSILON);
    assertTrue(Double.isNaN(similarity.itemSimilarity(1L, 4L)));

    EasyMock.verify(dataSource, connection, statement, resultSet);
  }
View Full Code Here

    ItemSimilarity similarity = new MySQLJDBCInMemoryItemSimilarity(dataSource);

    assertEquals(0.5, similarity.itemSimilarity(1L, 2L), EPSILON);
    assertEquals(0.4, similarity.itemSimilarity(1L, 3L), EPSILON);
    assertEquals(0.1, similarity.itemSimilarity(3L, 4L), EPSILON);
    assertTrue(Double.isNaN(similarity.itemSimilarity(1L, 4L)));

    EasyMock.verify(dataSource, connection, statement, resultSet);
  }
}
View Full Code Here

    ItemSimilarity similarity = new MySQLJDBCInMemoryItemSimilarity(dataSource);

    assertEquals(0.5, similarity.itemSimilarity(1L, 2L), EPSILON);
    assertEquals(0.4, similarity.itemSimilarity(1L, 3L), EPSILON);
    assertEquals(0.1, similarity.itemSimilarity(3L, 4L), EPSILON);
    assertTrue(Double.isNaN(similarity.itemSimilarity(1L, 4L)));

    EasyMock.verify(dataSource, connection, statement, resultSet);
  }
}
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.