All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.etsy.conjecture.data.ClusterPrediction Maven / Gradle / Ivy

There is a newer version: 0.2.3
Show newest version
package com.etsy.conjecture.data;

import java.util.Map;
import com.google.common.collect.Maps;

/**
 * Representing a probability of membership in each cluster
 */
public class ClusterPrediction extends ClusterLabel{

    private static final long serialVersionUID = -1L;

    /**
     * Cluster membership probabilities
     */
    private Map clusterProbs;

    public ClusterPrediction(Map clusterProbs) {
        this.clusterProbs = Maps.newHashMap(clusterProbs);
        boolean first = true;
        double maxProb = 0;
        String maxCategory = null;
        for (String key : clusterProbs.keySet()) {
            if(first || clusterProbs.get(key) > maxProb) {
              maxProb = clusterProbs.get(key);
              maxCategory = key;
              first = false;
            }
        }
        setLabel(maxCategory);
    }

    public Map getMap() {
        return clusterProbs;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy