Package org.grouplens.lenskit.util

Examples of org.grouplens.lenskit.util.ScoredItemAccumulator


            SparseVector vec1 = buildContext.itemVector(itemId1);

            LongIterator itemIter = neighborStrategy.neighborIterator(buildContext, itemId1,
                                                                      itemSimilarity.isSymmetric());

            ScoredItemAccumulator row = rows.get(itemId1);
            while (itemIter.hasNext()) {
                long itemId2 = itemIter.nextLong();
                if (itemId1 != itemId2) {
                    SparseVector vec2 = buildContext.itemVector(itemId2);
                    double sim = itemSimilarity.similarity(itemId1, vec1, itemId2, vec2);
                    if (threshold.retain(sim)) {
                        row.put(itemId2, sim);
                        if (itemSimilarity.isSymmetric()) {
                            rows.get(itemId2).put(itemId1, sim);
                        }
                    }
                }
View Full Code Here


    private Long2ObjectMap<ScoredItemAccumulator> makeAccumulators(LongSet items) {
        Long2ObjectMap<ScoredItemAccumulator> rows = new Long2ObjectOpenHashMap<ScoredItemAccumulator>(items.size());
        LongIterator iter = items.iterator();
        while (iter.hasNext()) {
            long item = iter.nextLong();
            ScoredItemAccumulator accum;
            if (modelSize == 0) {
                accum = new UnlimitedScoredItemAccumulator();
            } else {
                accum = new TopNScoredItemAccumulator(modelSize);
            }
View Full Code Here

        if (n < 0) {
            n = scores.size();
        }

        ScoredItemAccumulator accum = new TopNScoredItemAccumulator(n);
        for (VectorEntry pred : scores) {
            final double v = pred.getValue();
            accum.put(pred.getKey(), v);
        }

        return accum.finish();
    }
View Full Code Here

        if (n < 0) {
            n = scores.size();
        }

        ScoredItemAccumulator accum = new TopNScoredItemAccumulator(n);
        for (VectorEntry pred : scores) {
            final double v = pred.getValue();
            accum.put(pred.getKey(), v);
        }

        List<ScoredId> results = accum.finish();
        if (!scores.getChannelSymbols().isEmpty()) {
            ScoredIdListBuilder builder = ScoredIds.newListBuilder(results.size());
            List<Pair<Symbol,SparseVector>> cvs = Lists.newArrayList();
            List<Pair<TypedSymbol<?>, Long2ObjectMap<?>>> channels = Lists.newArrayList();
            for (Symbol sym: scores.getChannelVectorSymbols()) {
View Full Code Here

            if (input == null) {
                return LongSets.EMPTY_SET;
            }
            LenskitRecommender rec = (LenskitRecommender) input;
            ItemEventDAO idao = rec.get(ItemEventDAO.class);
            ScoredItemAccumulator accum = new TopNScoredItemAccumulator(count);
            Cursor<ItemEventCollection<Event>> items = idao.streamEventsByItem();
            try {
                for (ItemEventCollection<Event> item: items) {
                    accum.put(item.getItemId(), item.size());
                }
            } finally {
                items.close();
            }
            return accum.finishSet();
        }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.util.ScoredItemAccumulator

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.