Package org.grouplens.lenskit.transform.quantize

Examples of org.grouplens.lenskit.transform.quantize.Quantizer


        SparseVector predictions = user.getPredictions();
        if (predictions == null) {
            return null;
        }

        Quantizer q = context.quantizer;

        // TODO Re-use accumulators
        MutualInformationAccumulator accum = new MutualInformationAccumulator(q.getCount());

        for (Pair<VectorEntry,VectorEntry> e: Vectors.fastIntersect(ratings, predictions)) {
            accum.count(q.index(e.getLeft().getValue()),
                        q.index(e.getRight().getValue()));
        }

        if (accum.getCount() > 0) {
            double ratingEntropy = accum.getV1Entropy();
            double predEntropy = accum.getV2Entropy();
View Full Code Here


* @author <a href="http://www.grouplens.org">GroupLens Research</a>
*/
public class ValueArrayQuantizerTest {
    @Test
    public void testFindSingle() {
        Quantizer q = new ValueArrayQuantizer(new double[]{5.0});
        assertThat(q.getCount(), equalTo(1));
        assertThat(q.getIndexValue(0), equalTo(5.0));
        assertThat(q.index(2.5), equalTo(0));
        assertThat(q.index(5.0), equalTo(0));
    }
View Full Code Here

        assertThat(q.index(5.0), equalTo(0));
    }

    @Test
    public void testSomeElements() {
        Quantizer q = new ValueArrayQuantizer(new double[]{1.0, 2.0, 3.0, 4.0, 5.0});
        assertThat(q.getCount(), equalTo(5));
        assertThat(q.getIndexValue(0), equalTo(1.0));
        assertThat(q.index(2.5), equalTo(2));
        assertThat(q.index(5.0), equalTo(4));
        assertThat(q.index(1.73), equalTo(1));
    }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.transform.quantize.Quantizer

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.