Package it.unimi.dsi.fastutil.longs

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


            this.matcher = matcher;
        }

        @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());
                }
            }
            return items;
        }
View Full Code Here


            this.base = base;
        }

        @Override
        public LongSet select(TestUser user) {
            LongSet universe = UNIVERSE_CACHE.getUnchecked(user.getRecommender());
            return LongUtils.setDifference(universe, base.select(user));
        }
View Full Code Here

            this.selectorToNotKeep = selectorToNotKeep;
        }

        @Override
        public LongSet select(TestUser user) {
            LongSet l1 = selectorToKeep.select(user);
            LongSet l2 = selectorToNotKeep.select(user);
            return LongUtils.setDifference(l1, l2);
        }
View Full Code Here

            this.selectorTwo = selectorTwo;
        }

        @Override
        public LongSet select(TestUser user) {
            LongSet items = new LongOpenHashSet(selectorOne.select(user));
            items.addAll(selectorTwo.select(user));
            return items;
        }
View Full Code Here

                rng = lkr.get(Random.class);
            }
            if (rng == null) {
                rng = new Random();
            }
            LongSet items = delegate.select(user);
            if (items.size() <= count) {
                return items;
            }
            return LongUtils.randomSubset(items, count, rng);
        }
View Full Code Here

    @Override
    public Result doMeasureUser(TestUser user, Context context) {
        int tp = 0;
        int fp = 0;

        LongSet items = queryItems.select(user);

        List<ScoredId> recs = user.getRecommendations(listSize, candidates, exclude);
        if (recs == null) {
            return null;
        }

        for(ScoredId s : recs) {
            if(items.contains(s.getId())) {
                tp += 1;
            } else {
                fp += 1;
            }
        }
        int fn = items.size() - tp;

        if (items.size() > 0 && recs.size() > 0) {
            // if both the items set and recommendations are non-empty (no division by 0).
            double precision = (double) tp/(tp+fp);
            double recall = (double) tp/(tp+fn);
            context.addUser(precision, recall);
            return new Result(precision, recall);
View Full Code Here

     * @param damping   A damping term for deviation calculations.
     * @param dao       The DataAccessObject interfacing with the data for the model
     */
    public SlopeOneModelDataAccumulator(double damping, ItemDAO dao) {
        this.damping = damping;
        LongSet items = dao.getItemIds();

        workMatrix = new Long2ObjectOpenHashMap<MutableSparseVector>(items.size());
        LongIterator iter = items.iterator();
        while (iter.hasNext()) {
            long item = iter.nextLong();
            workMatrix.put(item, MutableSparseVector.create(items));
            workMatrix.get(item).addChannelVector(SlopeOneModel.CORATINGS_SYMBOL);
        }
View Full Code Here

    /**
     * Constructs and returns a {@link SlopeOneModel}.
     */
    @Override
    public SlopeOneModel get() {
        LongSet items = buildContext.getItems();
        LongIterator outer = items.iterator();
        while (outer.hasNext()) {
            final long item1 = outer.nextLong();
            final SparseVector vec1 = buildContext.itemVector(item1);
            LongIterator inner = items.iterator();
            while (inner.hasNext()) {
                final long item2 = inner.nextLong();
                if (item1 != item2) {
                    SparseVector vec2 = buildContext.itemVector(item2);
                    accumulator.putItemPair(item1, vec1, item2, vec2);
View Full Code Here

    public void testAllItem() {
        TestUser user = MockTestUser.newBuilder()
                                    .setUserId(42)
                                    .setRecommender(recommender)
                                    .build();
        LongSet items = ItemSelectors.allItems().select(user);
        assertThat(items, containsInAnyOrder(42L, 39L, 67L));
    }
View Full Code Here

        TestUser user = MockTestUser.newBuilder()
                                    .setUserId(42)
                                    .addTestRating(88, 3.5)
                                    .setRecommender(recommender)
                                    .build();
        LongSet items = ItemSelectors.testItems().select(user);
        assertThat(items, containsInAnyOrder(88L));
    }
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.