Package it.unimi.dsi.fastutil.longs

Examples of it.unimi.dsi.fastutil.longs.LongSet


     */
    private Vectors() {}

    @SuppressWarnings({"rawtypes", "unchecked"})
    public static MutableSparseVector fromScoredIds(List<ScoredId> scores) {
        LongSet ids = new LongOpenHashSet();
        for (ScoredId sid: scores) {
            ids.add(sid.getId());
        }
        MutableSparseVector vec = MutableSparseVector.create(ids);
        for (ScoredId sid: scores) {
            long id = sid.getId();
            if (!vec.containsKey(id)) {
View Full Code Here


   
    @Test
    public void testKeySet() {
        assertTrue(emptySideChannel().keySet().isEmpty());
        assertTrue(emptyDomainSideChannel().keySet().isEmpty());
        LongSet expected = new LongArraySet(new long[]{1,2,4});
        assertEquals(expected, simpleSideChannel().keySet());
    }
View Full Code Here

   
    @Test
    public void testKeySet() {
        assertTrue(emptySideChannel().keySet().isEmpty());
        assertTrue(emptyDomainSideChannel().keySet().isEmpty());
        LongSet expected = new LongArraySet(new long[]{1,2,4});
        assertEquals(expected, simpleSideChannel().keySet());
    }
View Full Code Here

    @Override
    public void predict(long user, @Nonnull MutableSparseVector scores) {
        itemScorer.score(user, scores);
        if (baselineScorer != null) {
            LongSet unset = scores.unsetKeySet();
            if (!unset.isEmpty()) {
                SparseVector bscores = baselineScorer.score(user, unset);
                scores.set(bscores);
            }
        }
        quantize(scores);
View Full Code Here

        List<Rating> ratings = getEventsForItem(item, Rating.class);
        if (ratings == null) {
            return null;
        }

        LongSet users = new LongOpenHashSet(ratings.size());
        for (Rating rating: ratings) {
            users.add(rating.getUserId());
        }
        return users;
    }
View Full Code Here

     * <p>Delegates to {@link #globalRecommend(LongSet, int, LongSet, LongSet)}.
     */
    @Override
    public List<ScoredId> globalRecommend(Set<Long> items, int n, @Nullable Set<Long> candidates,
                                          @Nullable Set<Long> exclude) {
        LongSet it = LongUtils.asLongSet(items);
        LongSet cs = LongUtils.asLongSet(candidates);
        LongSet es = LongUtils.asLongSet(exclude);
        return globalRecommend(it, n, cs, es);
    }
View Full Code Here

        List<Event> events = getEventsForItem(item);
        if (events == null) {
            return null;
        }

        LongSet users = new LongOpenHashSet();
        for (Event evt: events) {
            users.add(evt.getUserId());
        }
        return users;
    }
View Full Code Here

    }

    @Override
    public void predict(long user, @Nonnull MutableSparseVector scores) {
        scorer.score(user, scores);
        LongSet fallbackKeys = LongSets.EMPTY_SET;

        if (baselineScorer != null) {
            fallbackKeys = scores.unsetKeySet();
            MutableSparseVector unpred = MutableSparseVector.create(fallbackKeys);
            baselineScorer.score(user, unpred);
            scores.set(unpred);
        }

        // FIXME Make this faster
        Long2ObjectMap<ScoreSource> chan = scores.getOrAddChannel(PREDICTION_SOURCE_SYMBOL);
        for (VectorEntry e: scores) {
            long key = e.getKey();
            ScoreSource source = ScoreSource.PRIMARY;
            if (fallbackKeys.contains(key)) {
                source = ScoreSource.BASELINE;
            }
            chan.put(key, source);
        }
View Full Code Here

     */
    @Override
    public List<ScoredId> recommend(long user, int n,
                                    @Nullable Set<Long> candidates,
                                    @Nullable Set<Long> exclude) {
        LongSet cs = LongUtils.asLongSet(candidates);
        LongSet es = LongUtils.asLongSet(exclude);
        return recommend(user, n, cs, es);
    }
View Full Code Here

            for (Metric<?> eval: outputs.getMetrics()) {
                accumulators.add(makeMetricAccumulator(eval));
            }

            LongSet testUsers = dataSet.getTestData().getUserDAO().getUserIds();
            final NumberFormat pctFormat = NumberFormat.getPercentInstance();
            pctFormat.setMaximumFractionDigits(2);
            pctFormat.setMinimumFractionDigits(2);
            final int nusers = testUsers.size();
            logger.info("Testing {} on {} ({} users)", algorithmInfo, dataSet, nusers);
            int ndone = 0;
            for (LongIterator iter = testUsers.iterator(); iter.hasNext();) {
                if (Thread.interrupted()) {
                    throw new InterruptedException("eval job interrupted");
                }
                long uid = iter.nextLong();
                userRow.add(uid);
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.longs.LongSet

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.