Package org.grouplens.lenskit.util

Examples of org.grouplens.lenskit.util.TopNScoredItemAccumulator


            long item = iter.nextLong();
            ScoredItemAccumulator accum;
            if (modelSize == 0) {
                accum = new UnlimitedScoredItemAccumulator();
            } else {
                accum = new TopNScoredItemAccumulator(modelSize);
            }
            rows.put(item, accum);
        }
        return rows;
    }
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

    public void truncate(MutableSparseVector v) {
        if (threshold != null) {
            threshold.truncate(v);
        }

        TopNScoredItemAccumulator accumulator = new TopNScoredItemAccumulator(n);
        for (VectorEntry e : v.view(VectorEntry.State.SET)) {
            accumulator.put(e.getKey(), e.getValue());
        }
        MutableSparseVector truncated = accumulator.finishVector();

        // retain only the truncated keys
        v.keySet().retainAll(truncated.keySet());
    }
View Full Code Here

TOP

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

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.