Package org.grouplens.lenskit.vectors

Examples of org.grouplens.lenskit.vectors.MutableSparseVector.fill()


                           NeighborhoodScorer scorer) {
        Predicate<ScoredId> usable = new VectorKeyPredicate(userData);

        // Create a channel for recording the neighborhoodsize
        MutableSparseVector sizeChannel = scores.getOrAddChannelVector(ItemItemScorer.NEIGHBORHOOD_SIZE_SYMBOL);
        sizeChannel.fill(0);
        // for each item, compute its prediction
        for (VectorEntry e : scores.view(VectorEntry.State.EITHER)) {
            final long item = e.getKey();

            // find all potential neighbors
View Full Code Here


            final long rowItem = itemDomain.getKey(i);
            final SparseVector vec1 = buildContext.itemVector(rowItem);

            // Take advantage of sparsity if we can
            LongIterator neighbors = iterationStrategy.neighborIterator(buildContext, rowItem, false);
            currentRow.fill(0);

            // Compute similarities and populate the vector
            while (neighbors.hasNext()) {
                final long colItem = neighbors.nextLong();
                final SparseVector vec2 = buildContext.itemVector(colItem);
View Full Code Here

        }

        LongSet ts = LongUtils.setUnion(vec1.keySet(),vec2.keySet());

        MutableSparseVector v1 = MutableSparseVector.create(ts);
        v1.fill(0);
        v1.set(vec1);
        v1.multiply(1.0 / v1.norm());
        v1.addScaled(vec2, -1.0 / vec2.norm());

        distance = v1.norm();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.