Interface implemented by "user-based" recommenders.
136137138139140141142143144145146147
assertEquals(0.1f, firstRecommended.getValue(), EPSILON); } @Test public void testMostSimilar() throws Exception { UserBasedRecommender recommender = buildRecommender(); long[] similar = recommender.mostSimilarUserIDs(1, 2); assertNotNull(similar); assertEquals(2, similar.length); assertEquals(2, similar[0]); assertEquals(3, similar[1]); }
156157158159160161162163164165
{0.4, 0.4, 0.5, 0.9}, {null, null, null, null, 1.0}, }); UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel); UserNeighborhood neighborhood = new NearestNUserNeighborhood(3, similarity, dataModel); UserBasedRecommender recommender = new GenericUserBasedRecommender(dataModel, neighborhood, similarity); long[] mostSimilar = recommender.mostSimilarUserIDs(4, 3); assertNotNull(mostSimilar); assertEquals(0, mostSimilar.length); }