Example usage for org.apache.mahout.clustering.kmeans Kluster getIdentifier

List of usage examples for org.apache.mahout.clustering.kmeans Kluster getIdentifier

Introduction

In this page you can find the example usage for org.apache.mahout.clustering.kmeans Kluster getIdentifier.

Prototype

@Override
    public String getIdentifier() 

Source Link

Usage

From source file:sigis.kmeansmultiplek.AnotherKmeans.java

private void writeClusterInitialCenters(final Configuration conf, List<DenseVector> points) throws IOException {
    final Path writerPath = new Path(CLUSTERS_PATH + "/part-00000");

    final SequenceFile.Writer writer = SequenceFile.createWriter(conf, SequenceFile.Writer.file(writerPath),
            SequenceFile.Writer.keyClass(Text.class), SequenceFile.Writer.valueClass(Kluster.class));

    Random rand = new Random();
    for (int i = 0; i < numberOfCluster; i++) {
        int randomNum = rand.nextInt((points.size() - 0) + 1);
        final Vector vec = points.get(randomNum);

        // write the initial centers
        final Kluster cluster = new Kluster(vec, i, new EuclideanDistanceMeasure());
        writer.append(new Text(cluster.getIdentifier()), cluster);
    }//  w  w  w.  ja v a  2 s.com

    writer.close();
}