Package org.grouplens.lenskit.vectors

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


        if(values.length != getObjectCount()){
            throw new IllegalArgumentException("Value array has incorrect length");
        }

        MutableSparseVector newSparseVector = MutableSparseVector.create(ids);
        for(VectorEntry e : newSparseVector.view(State.EITHER)){
            final int iid = getIndex(e.getKey());
            newSparseVector.set(e, values[iid]);
        }
        return newSparseVector;
    }
View Full Code Here


        VectorTruncator truncator = new TopNTruncator(3, null);
        truncator.truncate(v);

        long i = 3;
        for (VectorEntry e : v.view(VectorEntry.State.SET)) {
            assertThat(e.getKey(), equalTo(i));
            assertThat(e.getValue(), closeTo(i, EPSILON));
            i++;
        }
        assertThat(i, equalTo(6L));
View Full Code Here

        VectorTruncator truncator = new ThresholdTruncator(new RealThreshold(3.5));
        truncator.truncate(v);

        int numSeen = 0;
        for (VectorEntry e : v.view(VectorEntry.State.SET)) {
            assertThat(e.getKey(), equalTo(4L));
            assertThat(e.getValue(), closeTo(4.0, EPSILON));
            numSeen++;
        }
        assertThat(numSeen, equalTo(1));
View Full Code Here

        VectorTruncator truncator = new NoOpTruncator();
        truncator.truncate(v);

        long i = 1;
        for (VectorEntry e : v.view(VectorEntry.State.SET)) {
            assertThat(e.getKey(), equalTo(i));
            assertThat(e.getValue(), closeTo(i, EPSILON));
            i++;
        }
        assertThat(i, equalTo(5L));
View Full Code Here

        int tailStart = feature + 1;
        int tailSize = featureCount - feature - 1;
        AVector utail = uprefs.subVector(tailStart, tailSize);
        MutableSparseVector tails = MutableSparseVector.create(ratings.keySet());
        for (VectorEntry e: tails.view(VectorEntry.State.EITHER)) {
            AVector ivec = model.getItemVector(e.getKey());
            if (ivec == null) {
                // FIXME Do this properly
                tails.set(e, 0);
            } else {
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.