Example usage for org.apache.mahout.clustering.canopy Canopy getCenter

List of usage examples for org.apache.mahout.clustering.canopy Canopy getCenter

Introduction

In this page you can find the example usage for org.apache.mahout.clustering.canopy Canopy getCenter.

Prototype

@Override
    public Vector getCenter() 

Source Link

Usage

From source file:cc.recommenders.mining.calls.clustering.CombinedKmeansAndCanopyClusteredPatternFinder.java

License:Open Source License

private List<Cluster> buildClusters(List<Canopy> canopies, DistanceMeasure distanceMeasure) {
    List<Cluster> clusters = new ArrayList<Cluster>();
    int i = 0;//from w w w  .ja v a 2s  .c o m
    for (Canopy canopy : canopies) {
        Cluster c = new Cluster(canopy.getCenter(), i, distanceMeasure);
        clusters.add(c);
        i++;
    }
    return clusters;
}

From source file:edu.indiana.d2i.htrc.kmeans.MemKMeansUtil.java

License:Apache License

/** Configure the mapper with the cluster info */
public static void configureWithClusterInfo(Configuration conf, Path clusterPath,
        Collection<Cluster> clusters) {
    for (Writable value : new SequenceFileDirValueIterable<Writable>(clusterPath, PathType.LIST,
            PathFilters.partFilter(), conf)) {
        Class<? extends Writable> valueClass = value.getClass();
        if (valueClass.equals(Cluster.class)) {
            // get the cluster info
            clusters.add((Cluster) value);
        } else if (valueClass.equals(Canopy.class)) {
            // get the cluster info
            Canopy canopy = (Canopy) value;
            clusters.add(new Cluster(canopy.getCenter(), canopy.getId(), canopy.getMeasure()));
        } else {/*from w  w w . ja v a2  s  . com*/
            throw new IllegalStateException("Bad value class: " + valueClass);
        }
    }
}