Package org.grouplens.lenskit

Examples of org.grouplens.lenskit.RatingPredictor


    }

    @Override
    public SparseVector getPredictions() {
        if (predictionCache == null) {
            RatingPredictor pred = recommender.getRatingPredictor();
            if (pred != null) {
                predictionCache = pred.predict(getUserId(), getTestRatings().keySet());
            }
        }
        return predictionCache;
    }
View Full Code Here


    public void testSlopeOneRecommenderEngineCreate() {
        Recommender rec = engine.createRecommender();

        assertThat(rec.getItemScorer(),
                   instanceOf(SlopeOneItemScorer.class));
        RatingPredictor rp = rec.getRatingPredictor();
        assertThat(rp, instanceOf(SimpleRatingPredictor.class));
        assertThat(((SimpleRatingPredictor) rp).getScorer(),
                   sameInstance(rec.getItemScorer()));
        assertThat(rec.getItemRecommender(),
                   instanceOf(TopNItemRecommender.class));
View Full Code Here

                                         .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));
        assertThat(vec.get(2), equalTo(2.5));
        assertThat(vec.get(3), equalTo(3.0));
        assertThat(vec.getChannel(FallbackItemScorer.SCORE_SOURCE_SYMBOL).get(1),
View Full Code Here

        assertThat(rec.getItemScorer(),
                   instanceOf(FunkSVDItemScorer.class));
        assertThat(rec.getItemRecommender(),
                   instanceOf(TopNItemRecommender.class));
        RatingPredictor pred = rec.getRatingPredictor();
        assertThat(pred, instanceOf(SimpleRatingPredictor.class));
        assertThat(((SimpleRatingPredictor) pred).getScorer(),
                   sameInstance(rec.getItemScorer()));
        assertThat(((FunkSVDItemScorer) rec.getItemScorer()).getUpdateRule(),
                   nullValue());
View Full Code Here

        long user = options.getLong("user");
        List<Long> items = options.get("items");

        LenskitRecommender rec = engine.createRecommender();
        RatingPredictor pred = rec.getRatingPredictor();
        if (pred == null) {
            logger.error("recommender has no rating predictor");
            throw new UnsupportedOperationException("no rating predictor");
        }

        logger.info("predicting {} items", items.size());
        Symbol pchan = getPrintChannel();
        Stopwatch timer = Stopwatch.createStarted();
        SparseVector preds = pred.predict(user, items);
        Long2ObjectMap channel = null;
        if (pchan != null) {
            for (TypedSymbol sym: preds.getChannelSymbols()) {
                if (sym.getRawSymbol().equals(pchan)) {
                    channel = preds.getChannel(sym);
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.RatingPredictor

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.