Package org.grouplens.lenskit.util.statistics

Examples of org.grouplens.lenskit.util.statistics.MutualInformationAccumulator


     * @return The similarity between the two vectors, based on mutual information.
     * @see VectorSimilarity#similarity(SparseVector, SparseVector)
     */
    @Override
    public double similarity(SparseVector vec1, SparseVector vec2) {
        MutualInformationAccumulator accum = new MutualInformationAccumulator(quantizer.getCount());

        for (Pair<VectorEntry,VectorEntry> e: Vectors.fastIntersect(vec1, vec2)) {
            accum.count(quantizer.index(e.getLeft().getValue()),
                        quantizer.index(e.getRight().getValue()));
        }

        return accum.getMutualInformation();
    }
View Full Code Here


        }

        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();
            double info = accum.getMutualInformation();
            context.addUser(info, ratingEntropy, predEntropy);
            return new EntropyResult(info, ratingEntropy, predEntropy);
        } else {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.util.statistics.MutualInformationAccumulator

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.