Package org.grouplens.lenskit.vectors

Examples of org.grouplens.lenskit.vectors.SparseVector


        return new Context();
    }

    @Override
    public UserResult doMeasureUser(TestUser user, Context context) {
        SparseVector ratings = user.getTestRatings();
        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }
        double sse = 0;
        int n = 0;
View Full Code Here


     * {@inheritDoc}
     * <p>Delegate to {@link #globalScore(Collection, Collection)}.
     */
    @Override
    public double globalScore(@Nonnull Collection<Long> queryItems, long item) {
        SparseVector v = globalScore(queryItems, LongLists.singleton(item));
        return v.get(item, Double.NaN);
    }
View Full Code Here

        return gain;
    }

    @Override
    public Result doMeasureUser(TestUser user, MeanAccumulator context) {
        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }

        SparseVector ratings = user.getTestRatings();
        LongList ideal = ratings.keysByValue(true);
        LongList actual = predictions.keysByValue(true);
        double idealGain = computeDCG(ideal, ratings);
        double gain = computeDCG(actual, ratings);
        double score = gain / idealGain;
        context.add(score);
View Full Code Here

        }

        @Override
        public LongSet select(TestUser user) {
            LongSet items = new LongOpenHashSet();
            SparseVector vec = user.getTestRatings();
            for (VectorEntry e: vec) {
                if (matcher.matches(e.getValue())) {
                    items.add(e.getKey());
                }
            }
View Full Code Here

        LongList items = new LongArrayList(recs.size());
        for (ScoredId sid: recs) {
            items.add(sid.getId());
        }

        SparseVector scores = scorer.score(user, items);
        ScoredIdListBuilder builder = ScoredIds.newListBuilder(recs.size());
        builder.addChannel(ORIGINAL_SCORE_SYMBOL);
        for (ScoredId sid: recs) {
            // FIXME Make this not allocate so much memory
            builder.add(ScoredIds.copyBuilder(sid)
                                 .setScore(scores.get(sid.getId(), Double.NaN))
                                 .addChannel(ORIGINAL_SCORE_SYMBOL, sid.getScore())
                                 .build());
        }
        return builder.build();
    }
View Full Code Here

        }
    }

    @Override
    public Result doMeasureUser(TestUser user, MeanAccumulator context) {
        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }

        SparseVector ratings = user.getTestRatings();
        LongList ideal = ratings.keysByValue(true);
        LongList actual = predictions.keysByValue(true);
        double idealUtility = computeHLU(ideal, ratings);
        double actualUtility = computeHLU(actual, ratings);
        double u = actualUtility / idealUtility;
View Full Code Here

        LongSortedSet reqItems = scores.keyDomain();
        if(cachedId == user && cachedScores != null) {
            LongSortedSet cachedItems = cachedScores.keyDomain();
            if(!cachedItems.containsAll(reqItems)) {
                LongSortedSet diffItems = LongUtils.setDifference(reqItems, cachedItems);
                SparseVector newCache = scorer.score(user, diffItems);
                cachedScores = cachedScores.combineWith(newCache);
            }
            scores.set(cachedScores);
        } else {
            scorer.score(user, scores);
View Full Code Here

        return new Context(dataSet.getTrainingData().getPreferenceDomain());
    }

    @Override
    public EntropyResult doMeasureUser(TestUser user, Context context) {
        SparseVector ratings = user.getTestRatings();
        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }

        Quantizer q = context.quantizer;
View Full Code Here

        return new Context();
    }

    @Override
    public Coverage doMeasureUser(TestUser user, Context context) {
        SparseVector ratings = user.getTestRatings();
        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }
        int n = 0;
        int good = 0;
        for (VectorEntry e : ratings) {
            n += 1;
            if (predictions.containsKey(e.getKey())) {
                good += 1;
            }
        }
        context.addUser(n, good);
        return new Coverage(n, good);
View Full Code Here

        return new Context();
    }

    @Override
    public UserResult doMeasureUser(TestUser user, Context context) {
        SparseVector ratings = user.getTestRatings();
        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }
        double err = 0;
        int n = 0;
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.vectors.SparseVector

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.