Package org.grouplens.lenskit

Examples of org.grouplens.lenskit.ItemScorer


     * is around 5, for rating 8 is around 3. So for the Ordrec predictor, given a specific
     * score value, and test if it can return a matched rating.
     */
    @Test
    public void testOrdRecPrediction1() {
        ItemScorer scorer = PrecomputedItemScorer.newBuilder()
                .addScore(42, 1, 5)
                .addScore(42, 2, 2)
                .addScore(42, 3, 8)
                .addScore(42, 4, 8.2)
                .addScore(42, 5, 2.1)
View Full Code Here


     * is around 2, for rating 3 is around 3. So for the Ordrec predictor, given a specific
     * score value, and test if it can return a matched rating.
     */
    @Test
    public void testOrdRecPrediction2() {
        ItemScorer scorer = PrecomputedItemScorer.newBuilder()
                .addScore(42, 1, 2)
                .addScore(42, 2, 1)
                .addScore(42, 3, 3)
                .addScore(42, 4, 3)
                .addScore(42, 5, 1)
View Full Code Here

     * is around 1, for rating 3 is around 1.8. So for the Ordrec predictor, given a specific
     * score value, and test if it can return a matched rating.
     */
    @Test
    public void testOrdRecPrediction3() {
        ItemScorer scorer = PrecomputedItemScorer.newBuilder()
                .addScore(42, 1, 1)
                .addScore(42, 2, 0.2)
                .addScore(42, 3, 1.8)
                .addScore(42, 4, 1.8)
                .addScore(42, 5, 0.2)
View Full Code Here

    private static final double EPSILON = 1.0e-5;

    @Before
    public void setUp() throws Exception {
        ItemScorer scorer = PrecomputedItemScorer.newBuilder()
                                          .addScore(40, 1, 4.0)
                                          .addScore(40, 2, 5.5)
                                          .addScore(40, 3, -1)
                                          .build();
        PreferenceDomain domain = new PreferenceDomain(1, 5, 1);
View Full Code Here

        config.bind(EventDAO.class).to(EventCollectionDAO.create(rs));
        config.bind(ItemScorer.class).to(SlopeOneItemScorer.class);
        config.bind(PreferenceDomain.class).to(new PreferenceDomainBuilder(1, 5)
                                                       .setPrecision(1)
                                                       .build());
        ItemScorer predictor = LenskitRecommenderEngine.build(config)
                                                       .createRecommender()
                                                       .getItemScorer();

        assertEquals(7 / 3.0, predictor.score(2, 9), EPSILON);
        assertEquals(13 / 3.0, predictor.score(3, 6), EPSILON);
        assertEquals(2, predictor.score(4, 6), EPSILON);
        assertEquals(2, predictor.score(4, 9), EPSILON);
        assertEquals(2.5, predictor.score(5, 6), EPSILON);
        assertEquals(3, predictor.score(5, 7), EPSILON);
        assertEquals(3.5, predictor.score(5, 9), EPSILON);
        assertEquals(1.5, predictor.score(6, 6), EPSILON);
        assertEquals(2, predictor.score(6, 7), EPSILON);
        assertEquals(2.5, predictor.score(6, 9), EPSILON);
    }
View Full Code Here

        config.bind(EventDAO.class).to(EventCollectionDAO.create(rs));
        config.bind(ItemScorer.class).to(SlopeOneItemScorer.class);
        config.bind(PreferenceDomain.class).to(new PreferenceDomainBuilder(1, 5)
                                                       .setPrecision(1)
                                                       .build());
        ItemScorer predictor = LenskitRecommenderEngine.build(config)
                                                       .createRecommender()
                                                       .getItemScorer();

        assertEquals(5, predictor.score(1, 5), EPSILON);
        assertEquals(2.25, predictor.score(1, 6), EPSILON);
        assertEquals(5, predictor.score(2, 5), EPSILON);
        assertEquals(1.75, predictor.score(3, 4), EPSILON);
        assertEquals(1, predictor.score(3, 6), EPSILON);
    }
View Full Code Here

        config.bind(EventDAO.class).to(EventCollectionDAO.create(rs));
        config.bind(ItemScorer.class).to(WeightedSlopeOneItemScorer.class);
        config.bind(PreferenceDomain.class).to(new PreferenceDomainBuilder(1, 5)
                                                       .setPrecision(1)
                                                       .build());
        ItemScorer predictor = LenskitRecommenderEngine.build(config)
                                                       .createRecommender()
                                                       .getItemScorer();

        assertEquals(2.6, predictor.score(2, 9), EPSILON);
        assertEquals(4.2, predictor.score(3, 6), EPSILON);
        assertEquals(2, predictor.score(4, 6), EPSILON);
        assertEquals(2, predictor.score(4, 9), EPSILON);
        assertEquals(2.5, predictor.score(5, 6), EPSILON);
        assertEquals(3, predictor.score(5, 7), EPSILON);
        assertEquals(3.5, predictor.score(5, 9), EPSILON);
        assertEquals(1.5, predictor.score(6, 6), EPSILON);
        assertEquals(2, predictor.score(6, 7), EPSILON);
        assertEquals(2.5, predictor.score(6, 9), EPSILON);
    }
View Full Code Here

        config.bind(EventDAO.class).to(EventCollectionDAO.create(rs));
        config.bind(ItemScorer.class).to(WeightedSlopeOneItemScorer.class);
        config.bind(PreferenceDomain.class).to(new PreferenceDomainBuilder(1, 5)
                                                       .setPrecision(1)
                                                       .build());
        ItemScorer predictor = LenskitRecommenderEngine.build(config)
                                                       .createRecommender()
                                                       .getItemScorer();

        assertEquals(5, predictor.score(1, 5), EPSILON);
        assertEquals(2.25, predictor.score(1, 6), EPSILON);
        assertEquals(5, predictor.score(2, 5), EPSILON);
        assertEquals(1.75, predictor.score(3, 4), EPSILON);
        assertEquals(1, predictor.score(3, 6), EPSILON);
    }
View Full Code Here

     * Make sure that score sources are routed properly through the rating predictor and
     * fallback scorer.
     */
    @Test
    public void testDoubleFallback() {
        ItemScorer primary = PrecomputedItemScorer.newBuilder()
                                           .addScore(42, 1, 3.5)
                                           .build();
        ItemScorer base1 = PrecomputedItemScorer.newBuilder()
                                         .addScore(42, 1, 2.5)
                                         .addScore(42, 2, 2.5)
                                         .build();
        ItemScorer base2 = PrecomputedItemScorer.newBuilder()
                                         .addScore(42, 1, 3.0)
                                         .addScore(42, 2, 3.0)
                                         .addScore(42, 3, 3.0)
                                         .build();
        ItemScorer scorer = new FallbackItemScorer(primary, base1);
        RatingPredictor pred = new SimpleRatingPredictor(scorer, base2, null);
        MutableSparseVector vec = MutableSparseVector.create(1, 2, 3);
        pred.predict(42, vec);
        assertThat(vec.size(), equalTo(3));
        assertThat(vec.get(1), equalTo(3.5));
View Full Code Here

        return new GlobalMeanRatingItemScorer.Builder(dao).get();
    }

    @Test
    public void testMeanBaseline() {
        ItemScorer pred = makeGlobalMean();
        SparseVector pv = pred.score(10L, itemSet(2l));
        assertEquals(RATINGS_DAT_MEAN, pv.get(2l), 0.00001);
    }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.ItemScorer

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.