Example usage for org.apache.mahout.clustering.classify WeightedPropertyVectorWritable toString

List of usage examples for org.apache.mahout.clustering.classify WeightedPropertyVectorWritable toString

Introduction

In this page you can find the example usage for org.apache.mahout.clustering.classify WeightedPropertyVectorWritable toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:hk.newsRecommender.MatrixAndCluster.java

License:Open Source License

public static void clusterOutput2(Configuration conf, Path path) {
    try {//from w w  w. j ava2 s.co m
        FileSystem fs = FileSystem.get(conf);
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
        IntWritable key = new IntWritable();
        WeightedPropertyVectorWritable value = new WeightedPropertyVectorWritable();
        while (reader.next(key, value)) {
            System.out.println(value.toString() + " belongs to cluster " + key.toString());
        }
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:sigis.kmeansmultiplek.AnotherKmeans.java

private void readAndPrintOutputValues(final Configuration configuration) throws IOException {
    final Path input = new Path(OUTPUT_PATH + "/" + Cluster.CLUSTERED_POINTS_DIR + "/part-m-00000");
    //final Path input = new Path(OUTPUT_PATH + "/" + Cluster.FINAL_ITERATION_SUFFIX + "/part-r-00000");
    System.out.println(Cluster.FINAL_ITERATION_SUFFIX);
    System.out.println(Cluster.CLUSTERED_POINTS_DIR);

    final SequenceFile.Reader reader = new SequenceFile.Reader(configuration, SequenceFile.Reader.file(input));

    final IntWritable key = new IntWritable();
    final WeightedPropertyVectorWritable value = new WeightedPropertyVectorWritable();

    while (reader.next(key, value)) {
        LOG.info("{} belongs to cluster {}", value.toString(), key.toString());
        System.out.println(value.toString().substring(18, 28));
        LOG.info("belongs to cluster {}", key.toString());

    }/*  w ww . j  a  va  2  s. c  o  m*/
    reader.close();
}